home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mnyth3 / manythng.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-02  |  99.0 KB  |  3,068 lines

  1. VERSION 2.00
  2. Begin Form ManyThings 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   1845
  7.    ClientTop       =   1710
  8.    ClientWidth     =   7995
  9.    ControlBox      =   0   'False
  10.    Height          =   5010
  11.    Icon            =   MANYTHNG.FRX:0000
  12.    Left            =   1785
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   307
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   533
  17.    Top             =   1365
  18.    Width           =   8115
  19.    Begin Timer Tick 
  20.       Enabled         =   0   'False
  21.       Interval        =   50
  22.       Left            =   10
  23.       Top             =   10
  24.    End
  25.    Begin Label PasswordLabel 
  26.       Alignment       =   1  'Right Justify
  27.       BackColor       =   &H00FFFFFF&
  28.       BorderStyle     =   1  'Fixed Single
  29.       Caption         =   "Need Password    "
  30.       FontBold        =   -1  'True
  31.       FontItalic      =   0   'False
  32.       FontName        =   "MS Sans Serif"
  33.       FontSize        =   24
  34.       FontStrikethru  =   0   'False
  35.       FontUnderline   =   0   'False
  36.       Height          =   690
  37.       Left            =   2430
  38.       TabIndex        =   0
  39.       Top             =   3510
  40.       Visible         =   0   'False
  41.       Width           =   4470
  42.    End
  43. ' BackGround -- this form expands to fill the whole
  44. '   screen and is used as the back drop for all the
  45. '   drawing
  46. Option Explicit
  47. ' variables declared here
  48. Dim MouseX, MouseY ' Last position of the mouse moves
  49. Dim LastX As Integer, LastY As Integer
  50. 'Dim conv2x As Single, conv2y As Single
  51. Dim LastTime As Long
  52. Dim CurrentTime As Long
  53. Dim LinkTime As Long
  54. Dim PlotType As Integer
  55. Dim PlotInit As Integer
  56. Dim PlotEnd As Integer
  57. Dim RepeatIndex As Integer
  58. Dim Pointer As Integer
  59. Dim Mirror As Integer
  60. Dim RunMode As Integer
  61. Dim x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer
  62. Dim vx1 As Single, vy1 As Single, vx2 As Single, vy2 As Single
  63. Dim ax1 As Single, ax2 As Single, ay1 As Single, ay2 As Single
  64. Dim l As Long
  65. Dim m As Long
  66. Dim MaxSpeedX As Integer, MaxSpeedY As Integer
  67. Dim TimeInterval As Long
  68. Dim MaxTime As Long
  69. Dim Repeats As Integer
  70. Dim i As Integer
  71. Dim BoxHeight As Integer, BoxWidth As Integer
  72. Dim DC As Integer
  73. Dim Pattern As Long, Locked As Integer
  74. Dim Direction As Integer
  75. Dim Number As Integer
  76. Dim PicWidth As Integer, PicHeight As Integer
  77. Dim PriorityBreakPoints() As Single
  78. Dim Priorities() As Integer
  79. Dim TotalPriority As Single
  80. Dim MaxPlotType As Integer
  81. ' values for GetBrightNonGray:
  82. ' minimum magnitude squared of colors
  83. Const MinColor = 3000' was 10000
  84. ' minimum difference between colors
  85. Const MinDiff = 30
  86. 'Allocate Memory
  87. Dim x1a() As Integer
  88. Dim x2a() As Integer
  89. Dim y1a() As Integer
  90. Dim y2a() As Integer
  91. Dim x1da() As Integer
  92. Dim x2da() As Integer
  93. Dim y1da() As Integer
  94. Dim y2da() As Integer
  95. Dim x1sa() As Single
  96. Dim x2sa() As Single
  97. Dim y1sa() As Single
  98. Dim y2sa() As Single
  99. Dim vx1sa() As Single
  100. Dim vx2sa() As Single
  101. Dim vy1sa() As Single
  102. Dim vy2sa() As Single
  103. Dim ax1sa() As Single
  104. Dim ax2sa() As Single
  105. Dim ay1sa() As Single
  106. Dim ay2sa() As Single
  107. Dim Colors() As Long
  108. Dim DataPts() As Integer
  109. 'for filled polygons
  110. Dim Points() As POINTAPI
  111. Const PI = 3.14159265358979
  112. Const Sin45 = .707106781186547
  113. Const Cos45 = Sin45
  114. Const Sin22_5 = .38268343236509
  115. Const Cos22_5 = .923879532511287
  116. Const Sin11_25 = .195090322016128
  117. Const Cos11_25 = .98078528040323
  118. Const HighMirror = 10
  119. Function CheckIfValidSaver (NeedsMuchMemory As Integer) As Integer
  120.   'when in low memory mode the saver only runs the modules
  121.   'that draw on the screen, not those that manipulate
  122.   'bitmaps, savers that use more memory will pass
  123.   'NeedsMuchMemory as a non-zero value
  124.   If LowMemoryFlag = 0 Then 'if not low memory mode then done
  125.     CheckIfValidSaver = 1
  126.   Else
  127.     If NeedsMuchMemory <> 0 Then
  128.       LogFile ("Saver not valid in low memory: " + Str$(PlotType)), 0
  129.       NextSelection
  130.       CheckIfValidSaver = 0
  131.     Else
  132.       CheckIfValidSaver = 1
  133.     End If
  134.   End If
  135.   If Priorities(PlotType) = 0 Then
  136.     LogFile ("Saver disabled: " + Str$(PlotType)), 0
  137.     NextSelection
  138.     CheckIfValidSaver = 0
  139.   End If
  140. End Function
  141. Sub Circles ()
  142.   ' have a single elipse trace across the
  143.   ' screen with multiple previous copies following
  144.   ' it
  145.   Dim xRadius As Integer, yRadius As Integer
  146.   Dim HighMirror As Integer
  147.   ' if first time then initialize
  148.   If PlotInit = False Then
  149.    'see if we need to reset changes made from previous init
  150.    If PlotEnd = False Then
  151.     'check if saver is permitted to run
  152.     If CheckIfValidSaver(0) = 0 Then
  153.       Exit Sub
  154.     End If
  155.     PlotInit = True
  156.     Cls
  157.     ForeColor = QBColor(15)
  158.     'Set array size and clear the elements
  159.     ReDim x1a(MaxLines) As Integer
  160.     ReDim x2a(MaxLines) As Integer
  161.     ReDim y1a(MaxLines) As Integer
  162.     ReDim y2a(MaxLines) As Integer
  163.     Pointer = 1     ' start with array element 1
  164.     ' set index to count number of times to repeat color
  165.     '   to past maxvalue so that it will be recalculated
  166.     RepeatIndex = MaxLines + 1
  167.     'determine initial position of line
  168.     x1 = Rnd * ScaleWidth
  169.     x2 = Rnd * ScaleWidth
  170.     y1 = Rnd * ScaleHeight
  171.     y2 = Rnd * ScaleHeight
  172.     'set initial velocity
  173.     vx1 = 0
  174.     vx2 = 0
  175.     vy1 = 0
  176.     vy2 = 0
  177.     'set initial acceleration
  178.     ax1 = 0
  179.     ax2 = 0
  180.     ay1 = 0
  181.     ay2 = 0
  182.     'find background color
  183.     m = QBColor(0)
  184.     'Calculate velocity limits
  185.     MaxSpeedX = ScaleWidth * 15! / 800
  186.     MaxSpeedY = ScaleWidth * 15! / 600
  187.     'select mirroring method
  188.     HighMirror = 5
  189.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  190.   Else 'reset changes done by previous init
  191.     ClearScreen
  192.     'zero array sizes
  193.     ReDim x1a(0) As Integer
  194.     ReDim x2a(0) As Integer
  195.     ReDim y1a(0) As Integer
  196.     ReDim y2a(0) As Integer
  197.   End If
  198.   Else  ' put run code here
  199.     Tick.Enabled = False' disable timer until circles completed
  200.     ' check if time to get a new color
  201.     If RepeatIndex > RepeatCount Then
  202.     'set color
  203.     l = GetBrightNonGray()
  204.     RepeatIndex = 1
  205.     Else
  206.     RepeatIndex = RepeatIndex + 1
  207.     End If
  208.     'Delete original circle
  209.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  210.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  211.     If xRadius <> 0 Then
  212.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  213.     End If
  214.     DoEvents
  215.     Select Case Mirror
  216.     Case 1: 'mirror on x and y axis
  217.         
  218.         'Delete original circle mirrored on Y axis
  219.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  220.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  221.         If xRadius <> 0 Then
  222.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  223.         End If
  224.         DoEvents
  225.         'Delete original circle mirrored on X axis
  226.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  227.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  228.         If xRadius <> 0 Then
  229.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  230.         End If
  231.         DoEvents
  232.         'Delete original circle mirrored on origin
  233.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  234.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  235.         If xRadius <> 0 Then
  236.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  237.         End If
  238.         DoEvents
  239.     Case 2: 'mirror on Y axis
  240.         
  241.         'Delete original circle mirrored on Y axis
  242.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  243.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  244.         If xRadius <> 0 Then
  245.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  246.         End If
  247.         DoEvents
  248.     Case 3: 'mirror around center point
  249.         'Delete original circle mirrored on origin
  250.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  251.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  252.         If xRadius <> 0 Then
  253.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, m, , , yRadius / xRadius
  254.         End If
  255.         DoEvents
  256.     Case Else: ' otherwise ignore (i.e. no mirror)
  257.     End Select
  258.     'Save New Circle
  259.     x1a(Pointer) = x1
  260.     x2a(Pointer) = x2
  261.     y1a(Pointer) = y1
  262.     y2a(Pointer) = y2
  263.     Select Case Mirror
  264.     Case 1: 'mirror on x and y axis
  265.         
  266.         'Delete original circle mirrored on Y axis
  267.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  268.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  269.         If xRadius <> 0 Then
  270.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  271.         End If
  272.         DoEvents
  273.         'Delete original circle mirrored on X axis
  274.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  275.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  276.         If xRadius <> 0 Then
  277.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  278.         End If
  279.         DoEvents
  280.         'Delete original circle mirrored on origin
  281.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  282.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  283.         If xRadius <> 0 Then
  284.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  285.         End If
  286.     Case 2: 'mirror on Y axis
  287.         
  288.         'Delete original circle mirrored on y axis
  289.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  290.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  291.         If xRadius <> 0 Then
  292.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  293.         End If
  294.     Case 3: 'mirror around center point
  295.         'Delete original circle mirrored on origin
  296.         xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  297.         yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  298.         If xRadius <> 0 Then
  299.         Circle ((ScaleWidth - x1a(Pointer) + ScaleWidth - x2a(Pointer)) / 2, (ScaleHeight - y1a(Pointer) + ScaleHeight - y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  300.         End If
  301.     Case Else: ' otherwise ignore (i.e. no mirror)
  302.     End Select
  303.     DoEvents
  304.     Tick.Enabled = True' re-enable timer
  305.     'Draw new Circle
  306.     xRadius = Abs(x1a(Pointer) - x2a(Pointer)) / 2
  307.     yRadius = Abs(y1a(Pointer) - y2a(Pointer)) / 2
  308.     If xRadius <> 0 Then
  309.         Circle ((x1a(Pointer) + x2a(Pointer)) / 2, (y1a(Pointer) + y2a(Pointer)) / 2), xRadius, l, , , yRadius / xRadius
  310.     End If
  311.     'Move pointer to next item
  312.     Pointer = Pointer + 1
  313.     If Pointer > MaxLines Then
  314.         Pointer = 1
  315.     End If
  316.     'determine new acceleration
  317.     ax1 = Rnd - .5
  318.     ax2 = Rnd - .5
  319.     ay1 = Rnd - .5
  320.     ay2 = Rnd - .5
  321.     'calculate new position
  322.     x1 = x1 + vx1
  323.     x2 = x2 + vx2
  324.     y1 = y1 + vy1
  325.     y2 = y2 + vy2
  326.     'calculate new velocity
  327.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  328.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  329.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  330.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  331.     'check if off screen
  332.     If (x1 > ScaleWidth) Then
  333.         'change direction
  334.         vx1 = -Abs(vx1)
  335.     ElseIf (x1 < 0) Then
  336.         'change direction
  337.         vx1 = Abs(vx1)
  338.     End If
  339.     If (y1 > ScaleHeight) Then
  340.         'change direction
  341.         vy1 = -Abs(vy1)
  342.     ElseIf (y1 < 0) Then
  343.         'change direction
  344.         vy1 = Abs(vy1)
  345.     End If
  346.     If (x2 > ScaleWidth) Then
  347.         'change direction
  348.         vx2 = -Abs(vx2)
  349.     ElseIf (x2 < 0) Then
  350.         'change direction
  351.         vx2 = Abs(vx2)
  352.     End If
  353.     If (y2 > ScaleHeight) Then
  354.         'change direction
  355.         vy2 = -Abs(vy2)
  356.     ElseIf (y2 < 0) Then
  357.         'change direction
  358.         vy2 = Abs(vy2)
  359.     End If
  360.   End If
  361. End Sub
  362. Sub ClearScreen ()
  363. 'goes to extreme efforts to clear the screen
  364.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  365.   'clear display
  366.   BitBlt DC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &H42&
  367.   i = DeleteDC(DC)
  368.   picture = LoadPicture() ' clear picture
  369.   BackColor = QBColor(0)
  370.   Cls
  371. End Sub
  372. Sub Confetti ()
  373.   'put points on screen
  374.   'Dim i As Integer, j As Integer, k As Integer
  375.   Dim x As Integer, y As Integer
  376.   Dim Size As Integer
  377.   Dim UniformBoxes As Integer
  378.   ' if first time then initialize
  379.   If PlotInit = False Then
  380.     'see if we need to reset changes made from previous init
  381.     If PlotEnd = False Then
  382.       'check if saver is permitted to run
  383.       If CheckIfValidSaver(0) = 0 Then
  384.     Exit Sub
  385.       End If
  386.      If LowMemoryFlag = 0 Then 'if not low memory mode then done
  387.        picture = original.Image ' start with original screen
  388.      Else
  389.        Cls
  390.      End If
  391.       PlotInit = True
  392.       Size = Rnd * 5 + 1
  393.     Else 'reset changes done by previous init
  394.       Tick.Enabled = True
  395.       picture = LoadPicture()
  396.     End If
  397.   Else
  398.     Tick.Enabled = False
  399.     Size = Rnd * 5 + 1  ' size to make dots
  400.     If Rnd > .5 Then
  401.        UniformBoxes = True
  402.     Else
  403.        UniformBoxes = False
  404.     End If
  405.     Do
  406.       x = Int(Rnd * ScrnWidth)
  407.       y = Int(Rnd * ScrnHeight)
  408.       Line (x, y)-(x + Size, y + Size), GetNearestColor(hDC, RGB(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))), BF
  409.       If UniformBoxes = False Then
  410.     Size = Rnd ^ 10 * 40 + 2'new size
  411.       End If
  412.       DoEvents
  413.       CurrentTime = Timer
  414.       If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Do
  415.     Loop
  416.     Tick.Enabled = True
  417.     picture = LoadPicture()
  418.   End If
  419. End Sub
  420. Sub CyclePalette ()
  421.   Dim Header As Long, DataBits As Long, i As Integer, j As Integer
  422.   Dim l As Long
  423.   Dim Paint As PAINTSTRUCT
  424.   Static Xoffset As Integer, Yoffset As Integer, red As Integer, green As Integer, blue As Integer
  425.   Static Wdth As Integer, Hght As Integer
  426.   Static FastPalRunFlag As Integer, PassFlag As Integer
  427.   Dim FileName As String, File As String
  428.   Static PaletteFlag As Integer
  429.   ' if first time then initialize
  430.   If PlotInit = False Then
  431.     'see if we need to reset changes made from previous init
  432.     If PlotEnd = False Then
  433.     'check if saver is permitted to run
  434.     If CheckIfValidSaver(1) = 0 Then
  435.       Exit Sub
  436.     End If
  437.      'we only allow to run once since it has problems:
  438.      'if started more than once durring before program stops
  439.      'then resources can disappear drastically, there must
  440.      'be something about the animatepalette function or
  441.      'sendmessage that requires resources to be cleared?
  442.      If FastPalRunFlag Then
  443.        LogFile "Already ran Fast pallete cycle " + File, 1
  444.        NextSelection 'jump to next since there are no bitmap files in directory
  445.        Exit Sub
  446.      End If
  447.       '*****************************************************
  448.       'initialization code here:
  449.       File = GetNextFile(CycleBitmapsDir, 1, "dib", "gif", "")
  450.       If File = "" Then 'check if could not load
  451.     NextSelection 'jump to next since there are no bitmap files in directory
  452.     Exit Sub
  453.       End If
  454.       ' find file
  455.       'FileSpec = RTrim$(BitmapsDir) + "\*.dib"
  456.       j = Rnd * 50 ' pick file at random
  457.       For i = 1 To j
  458.     File = GetNextFile(CycleBitmapsDir, 0, "dib", "gif", "")' get next file
  459.       Next i
  460.       'i = LoadSlide(File, 1)
  461.       'If i = 0 Then 'check if could not load
  462.       '  LogFile "Could not load file " + File, 1
  463.       '  NextSelection 'jump to next since there are no bitmap files in directory
  464.       '  Exit Sub
  465.       'End If
  466.       If InStr(UCase$(File), ".GIF") = 0 Then
  467.     l = ManyDibLoad(File, Wdth, Hght)'load dib
  468.       
  469.     If l <= 0 Then 'check if could not load
  470.       LogFile "Could not read DIB file " + File, 1
  471.       NextSelection 'jump to next since there are no bitmap files in directory
  472.       Exit Sub
  473.     End If
  474.       
  475.       Else
  476.     l = ManyGifLoad(File, Wdth, Hght)'load gif
  477.       
  478.     If l <= 0 Then 'check if could not load
  479.       LogFile "Could not read GIF file " + File, 1
  480.       NextSelection 'jump to next since there are no bitmap files in directory
  481.       Exit Sub
  482.     End If
  483.       End If
  484.       If (TotalNumColors <= 256) And (FastPaletteCycleFlag <> 0) Then
  485.     FastPalRunFlag = 1
  486.     'free up all but 2 system palettes
  487.     i = SetSystemPaletteUse(hDC, SYSPAL_NOSTATIC)
  488.     'show the palettes
  489.     SetWindow2DIBPalette PC_RESERVED
  490.     LogFile "Using Fast Palette Cycling", 0
  491.     PaletteFlag = 1
  492.       Else 'don't mess with palettes
  493.     'picture = LoadPicture() ' clear screen
  494.     LogFile "Changing Palette using screen redraws", 0
  495.     PaletteFlag = 0
  496.       End If
  497.       PassFlag = 2
  498.       
  499.       PlotInit = True
  500.       'Cls
  501.       'position image
  502.       Xoffset = (ScrnWidth - Wdth) / 2
  503.       Yoffset = (ScrnHeight - Hght) / 2
  504.       'set tick rate
  505.       Tick.Interval = 25
  506.     Else 'reset changes done by previous init
  507.       If PaletteFlag <> 0 Then
  508.     'remove priority on palette entries
  509.     SetWindow2DIBPalette 0
  510.     i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  511.       End If
  512.       'try to read last temp file for background
  513.       i = LoadSlideAndTile(RTrim$(BitmapsDir) + "\tmprary.dib")
  514.       'save current screen as new original
  515.       DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  516.       BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  517.       i = DeleteDC(DC)
  518.       ClearScreen
  519.       i = ManyDibFree() 'free memory used for dib
  520.       If i <> 0 Then
  521.     LogFile "Could not free memory", 1
  522.       End If
  523.       'set tick rate
  524.       Tick.Interval = 50
  525.     End If
  526.   Else  ' put run code here
  527.     If PassFlag > 1 Then
  528.       Header = ManyDibGet() 'get pointer to header
  529.       DataBits = ManyDibGetData() 'get pointer to data
  530.       If Header <> 0 Then
  531.     i = SetStretchBltMode(hDC, 3)
  532.     i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, Wdth, Hght, DataBits, Header, 0, &HCC0020)'source copy
  533.       Else
  534.     LogFile "Header missing", 1
  535.     NextSelection
  536.     Exit Sub
  537.       End If
  538.       PassFlag = PassFlag - 1
  539.     Else
  540.       
  541.       Header = ManyDibGet() 'get pointer to header
  542.       DataBits = ManyDibGetData() 'get pointer to data
  543.       If Header <> 0 Then
  544.     If PaletteFlag <> 0 Then
  545.       DoAnimatePalette Pal, 1, 1'shift pallete by one
  546.     Else 'if not palette based, animate screen by
  547.          'changing colors and redrawing
  548.          
  549.       'draw screen
  550.       i = SetStretchBltMode(hDC, 3)
  551.       ManyDibCyclePalette -1, 1, 255'cycle colors
  552.       'i = StretchDIBits(hDC, 0, 0, ScrnWidth, ScrnHeight, 0, 0, 640, 480, DataBits, Header, 0, &HCC0020)'source copy
  553.       i = SetDIBitsToDevice(hDC, Xoffset, Yoffset, Wdth, Hght, 0, 0, 0, Hght, DataBits, Header, 0)
  554.     End If
  555.       Else
  556.     LogFile "Header missing", 1
  557.     NextSelection
  558.     Exit Sub
  559.       End If
  560.     End If
  561.   End If
  562.   Exit Sub
  563. End Sub
  564. Sub DoAnimatePalette (palette As LOGPALETTE, Start As Integer, StepSize As Integer)
  565. ' cycle palete entry and display
  566.     Dim entrynum%, i As Integer
  567.     Dim usepal As Integer
  568.     Dim holdentry As PALETTEENTRY
  569.     Dim temp As Long
  570.     For i = 1 To StepSize'shift n times
  571.       ' The following code simply loops the color values
  572.       LSet holdentry = palette.palPalEntry(Start)
  573.       For entrynum% = Start To PALENTRIES - 2
  574.     LSet palette.palPalEntry(entrynum%) = palette.palPalEntry(entrynum% + 1)
  575.       Next entrynum%
  576.       LSet palette.palPalEntry(PALENTRIES - 1) = holdentry
  577.     Next i
  578.     ' Get a handle to the control's palette
  579.     On Error GoTo 299
  580.     usepal = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  581.     On Error GoTo 0
  582.     AnimatePalette usepal, 0, PALENTRIES, palette.palPalEntry(0)
  583.     Exit Sub
  584. 299 'overflow on getting palette handle
  585.   On Error GoTo 0
  586.   LogFile "Overflow on getting palette handle", 1
  587.   Exit Sub
  588. End Sub
  589. Sub Dribble ()
  590.   'dribbling paint on screen
  591.   Dim i As Integer, j As Integer, k As Integer
  592.   Static MaxHole As Integer
  593.   ' if first time then initialize
  594.   If PlotInit = False Then
  595.     'see if we need to reset changes made from previous init
  596.     If PlotEnd = False Then
  597.     'check if saver is permitted to run
  598.     If CheckIfValidSaver(1) = 0 Then
  599.       Exit Sub
  600.     End If
  601.     ' start with original screen
  602.     picture = original.Image
  603.     PlotInit = True
  604.     'determine initial position of shot
  605.     x1 = Rnd * ScaleWidth
  606.     y1 = Rnd * ScaleHeight
  607.     'Calculate velocity limits
  608.     MaxSpeedX = ScaleWidth * 20! / 800
  609.     MaxSpeedY = ScaleWidth * 20! / 600
  610.     ' zero initial velocity
  611.     vx1 = 0: vy1 = 0
  612.     'set maximum size of holes
  613.     MaxHole = 4
  614.     ForeColor = RGB(0, 0, 0)' use black box
  615.     FillColor = RGB(0, 0, 0) 'set black fill
  616.     FillStyle = 0 'solid fill
  617.     RunMode = Int(Rnd * 2#)'choose black or color
  618.     'Debug.Print RunMode
  619.     If RunMode > 0 Then ' if random color then use larger spots
  620.     MaxHole = 8
  621.     i = Rnd * 255: If i > 255 Then i = 255
  622.     j = Rnd * 255: If j > 255 Then j = 255
  623.     k = Rnd * 255: If k > 255 Then k = 255
  624.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  625.     FillColor = ForeColor
  626.     End If
  627.   Else 'reset changes done by previous init
  628.     ClearScreen
  629.     FillStyle = 1 'transparent fill
  630.   End If
  631.   Else  ' put run code here
  632.     If RunMode > 0 Then ' see if need to change to random color
  633.         If Rnd < .05 Then
  634.         i = Rnd * 255: If i > 255 Then i = 255
  635.         j = Rnd * 255: If j > 255 Then j = 255
  636.         k = Rnd * 255: If k > 255 Then k = 255
  637.         ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  638.         FillColor = ForeColor
  639.         End If
  640.     End If
  641.     ' put random hole here
  642.     Circle (x1 + Rnd * 20, y1 + Rnd * 20), MaxHole * Rnd + 2, , , , 1
  643.     'determine new acceleration
  644.     ax1 = 2 * Rnd - 1
  645.     ay1 = 2 * Rnd - 1
  646.         
  647.     'calculate new position
  648.     x1 = x1 + vx1
  649.     y1 = y1 + vy1
  650.         
  651.     'calculate new velocity
  652.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ax1 = 0
  653.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vx1 = -vx1 * .9: vy1 = -vy1 * .9: ay1 = 0
  654.         
  655.     'check if off screen
  656.     If (x1 > ScaleWidth) Then
  657.         'change direction
  658.         vx1 = -Abs(vx1)
  659.     ElseIf (x1 < 0) Then
  660.         'change direction
  661.         vx1 = Abs(vx1)
  662.     End If
  663.     If (y1 > ScaleHeight) Then
  664.         'change direction
  665.         vy1 = -Abs(vy1)
  666.     ElseIf (y1 < 0) Then
  667.         'change direction
  668.         vy1 = Abs(vy1)
  669.     End If
  670.   End If
  671. End Sub
  672. Sub Drop ()
  673.   ' bitblt's with various patterns, dragging them
  674.   ' across the screen randomly
  675.   Dim j As Integer
  676.   Static OldY As Integer
  677.   Static NotFoundCount As Integer
  678.   Const MaxCount = 200
  679.   ' if first time then initialize
  680.   If PlotInit = False Then
  681.     'see if we need to reset changes made from previous init
  682.     If PlotEnd = False Then
  683.     'check if saver is permitted to run
  684.     If CheckIfValidSaver(1) = 0 Then
  685.       Exit Sub
  686.     End If
  687.     'store whether column has dropped
  688.     ReDim x1a(ScaleWidth)
  689.     ' start with original screen
  690.     picture = original.Image
  691.     PlotInit = True
  692.     'flag that no column has been chosen
  693.     x1 = -1
  694.     'Calculate velocity limits
  695.     MaxSpeedY = ScaleWidth * 10! / 600
  696.     MaxSpeedX = ScaleWidth * 10! / 800
  697.     ' zero initial velocity
  698.     vy1 = 0
  699.     'width of column to drop
  700.     BoxWidth = 10 + Rnd * 100
  701.     i = Int(Rnd * 2#)'if i=0 then do jagged drop
  702.     x2 = 0 'used for width change
  703.   Else 'reset changes done by previous init
  704.     'store whether column has dropped
  705.     ReDim x1a(0)
  706.     ClearScreen
  707.   End If
  708. Else  ' put run code here
  709.   If x1 < 0 Then 'see if found valid column
  710.     x1 = Rnd * ScaleWidth / BoxWidth 'choose a column
  711.     If x1a(x1) = 0 Then 'check if not yet dropped
  712.     y1 = 0 'start position
  713.     x1a(x1) = 1 'flag that column has already been used
  714.     x2 = 0: vx2 = 0: OldY = 0' initialize variables
  715.     NotFoundCount = 0
  716.     Else
  717.     x1 = -1 'flag that no column chosen
  718.     ' count column failures
  719.     NotFoundCount = NotFoundCount + 1
  720.     If NotFoundCount > MaxCount Then
  721.         'restart dropping
  722.         'reset whether column has dropped
  723.         ReDim x1a(ScaleWidth)
  724.         ' start with original screen
  725.         picture = original.Image
  726.     End If
  727.     End If
  728.   Else 'if column already found, then drop it
  729.     If i = 0 Then 'check if jagged drop
  730.     'make sure effective width does not get too small
  731.     If x2 >= BoxWidth - 5 Then
  732.     x2 = BoxWidth - 5
  733.     vx2 = -vx2 'reverse direction
  734.     End If
  735.     j = x2 / 2 'get half of change
  736.     'shift column
  737.     DC = original.hDC
  738.     BitBlt hDC, x1 * BoxWidth + j, y1, BoxWidth - x2, ScaleHeight - y1, DC, x1 * BoxWidth + j, 0, &HCC0020'source copy
  739.     'blank top of column
  740.     BitBlt hDC, x1 * BoxWidth + j, OldY, BoxWidth - x2, y1 - OldY + 1, DC, x1 * BoxWidth + j, 0, &H42'blackout
  741.     Else ' not jagged drop
  742.     'shift column
  743.     DC = original.hDC
  744.     BitBlt hDC, x1 * BoxWidth, y1, BoxWidth, ScaleHeight - y1, DC, x1 * BoxWidth, 0, &HCC0020  'source copy
  745.     'blank top of column
  746.     BitBlt hDC, x1 * BoxWidth, OldY, BoxWidth, y1 - OldY + 1, DC, x1 * BoxWidth, 0, &H42'blackout
  747.     End If
  748.     'save current position
  749.     OldY = y1
  750.     'check if off screen
  751.     If (y1 > ScaleHeight) Then
  752.     x1 = -1 'flag done
  753.     vy1 = 0'zero velocity again
  754.     End If
  755.     'determine new acceleration
  756.     ay1 = Rnd * .25
  757.     ax2 = Rnd * .25 - .125
  758.     'calculate new positions
  759.     y1 = y1 + vy1
  760.     x2 = x2 + vx2
  761.     'calculate new velocity
  762.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = vy1 / 2: ay1 = 0
  763.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = vx2 / 2: ax2 = 0
  764.     End If
  765.   End If
  766. End Sub
  767. Sub EndScrnSaveForm ()
  768.   LogFile "EndScrnSaveFrom: before freeing memory", 1
  769.   i = SetSystemPaletteUse(hDC, SYSPAL_STATIC)'restore system palette
  770.   i = ManyDibFree() 'free memory used for dib
  771.   If i <> 0 Then
  772.     LogFile "Could not free memory", 1
  773.   End If
  774.   picture = LoadPicture()
  775.   EndScrnSave 'call global screen saver
  776. End Sub
  777. Sub FilledCircles ()
  778.   ' have a single filled elipse trace across the screen
  779.   Dim i As Integer, j As Integer, k As Integer, n As Integer
  780.   Dim xRadius As Integer, yRadius As Integer
  781.   ' if first time then initialize
  782.   If PlotInit = False Then
  783.     'see if we need to reset changes made from previous init
  784.     If PlotEnd = False Then
  785.     'check if saver is permitted to run
  786.     If CheckIfValidSaver(0) = 0 Then
  787.       Exit Sub
  788.     End If
  789.     PlotInit = True
  790.     Cls
  791.     ForeColor = QBColor(15)
  792.     FillColor = ForeColor
  793.     BackColor = QBColor(0)
  794.     FillStyle = 0' use solid fill
  795.     ' set index to count number of times to repeat color
  796.     '   to past maxvalue so that it will be recalculated
  797.     RepeatIndex = MaxLines + 1
  798.     'determine initial position of line
  799.     x1 = Rnd * ScaleWidth
  800.     x2 = Rnd * ScaleWidth
  801.     y1 = Rnd * ScaleHeight
  802.     y2 = Rnd * ScaleHeight
  803.     'set initial velocity
  804.     vx1 = 0
  805.     vx2 = 0
  806.     vy1 = 0
  807.     vy2 = 0
  808.     'set initial acceleration
  809.     ax1 = 0
  810.     ax2 = 0
  811.     ay1 = 0
  812.     ay2 = 0
  813.     'find background color
  814.     'Calculate velocity limits
  815.     MaxSpeedX = ScaleWidth * 15! / 800
  816.     MaxSpeedY = ScaleWidth * 15! / 600
  817.   Else 'reset changes done by previous init
  818.     ClearScreen
  819.     FillStyle = 1 'transparent fill
  820.   End If
  821.   Else  ' put run code here
  822.     ' check if time to get a new color
  823.     If RepeatIndex > RepeatCount Then
  824.     ' get random fore ground color
  825.     i = Rnd * 255: If i > 255 Then i = 255
  826.     j = Rnd * 255: If j > 255 Then j = 255
  827.     k = Rnd * 255: If k > 255 Then k = 255
  828.     ForeColor = RGB(i, j, k)
  829.     ' get random fill color
  830.     i = Rnd * 255: If i > 255 Then i = 255
  831.     j = Rnd * 255: If j > 255 Then j = 255
  832.     k = Rnd * 255: If k > 255 Then k = 255
  833.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  834.     RepeatIndex = 1
  835.     Else
  836.     RepeatIndex = RepeatIndex + 1
  837.     End If
  838.     'Draw new Circle
  839.     xRadius = Abs(x1 - x2) / 2
  840.     yRadius = Abs(y1 - y2) / 2
  841.     If xRadius <> 0 Then
  842.         Circle ((x1 + x2) / 2, (y1 + y2) / 2), xRadius, , , , yRadius / xRadius
  843.     End If
  844.     'Move pointer to next item
  845.     Pointer = Pointer + 1
  846.     If Pointer > MaxLines Then
  847.         Pointer = 1
  848.     End If
  849.     'determine new acceleration
  850.     ax1 = Rnd - .5
  851.     ax2 = Rnd - .5
  852.     ay1 = Rnd - .5
  853.     ay2 = Rnd - .5
  854.     'calculate new position
  855.     x1 = x1 + vx1
  856.     x2 = x2 + vx2
  857.     y1 = y1 + vy1
  858.     y2 = y2 + vy2
  859.     'calculate new velocity
  860.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  861.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  862.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  863.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  864.     'check if off screen
  865.     If (x1 > ScaleWidth) Then
  866.         'change direction
  867.         vx1 = -Abs(vx1)
  868.     ElseIf (x1 < 0) Then
  869.         'change direction
  870.         vx1 = Abs(vx1)
  871.     End If
  872.     If (y1 > ScaleHeight) Then
  873.         'change direction
  874.         vy1 = -Abs(vy1)
  875.     ElseIf (y1 < 0) Then
  876.         'change direction
  877.         vy1 = Abs(vy1)
  878.     End If
  879.     If (x2 > ScaleWidth) Then
  880.         'change direction
  881.         vx2 = -Abs(vx2)
  882.     ElseIf (x2 < 0) Then
  883.         'change direction
  884.         vx2 = Abs(vx2)
  885.     End If
  886.     If (y2 > ScaleHeight) Then
  887.         'change direction
  888.         vy2 = -Abs(vy2)
  889.     ElseIf (y2 < 0) Then
  890.         'change direction
  891.         vy2 = Abs(vy2)
  892.     End If
  893.   End If
  894. End Sub
  895. Sub FilledPolygons ()
  896.   ' draw a randomly moving polygon on the screen
  897.   ' slightly offset from previous polygon
  898.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  899.   Static Sets As Integer
  900.   ' if first time then initialize
  901.   If PlotInit = False Then
  902.     'see if we need to reset changes made from previous init
  903.     If PlotEnd = False Then
  904.     'check if saver is permitted to run
  905.     If CheckIfValidSaver(0) = 0 Then
  906.       Exit Sub
  907.     End If
  908.     PlotInit = True
  909.     ForeColor = RGB(255, 255, 255)
  910.     BackColor = RGB(0, 0, 0)
  911.     FillStyle = 0' use solid fill
  912.     DrawWidth = 1' use narrow line
  913.     j = SetPolyFillMode(hDC, 2)' use winding fill mode
  914.     Cls
  915.     'set number of corners between 3 and 5
  916.     Sets = Rnd * 4 + 3
  917.     'Set array size and clear the elements
  918.     ReDim Points(Sets) As POINTAPI
  919.     ReDim vx1sa(Sets) As Single
  920.     ReDim vy1sa(Sets) As Single
  921.     ReDim ax1sa(Sets) As Single
  922.     ReDim ay1sa(Sets) As Single
  923.     'counter for changing colors, set to overflow
  924.     RepeatIndex = RepeatCount + 1
  925.     For j = 1 To Sets
  926.     'determine initial position of line
  927.     Points(j).x = Rnd * ScaleWidth
  928.     Points(j).y = Rnd * ScaleHeight
  929.     Next j
  930.     'Calculate velocity limits
  931.     MaxSpeedX = ScaleWidth * 15! / 800
  932.     MaxSpeedY = ScaleWidth * 15! / 600
  933.   Else 'reset changes done by previous init
  934.     ReDim Points(0) As POINTAPI
  935.     ReDim vx1sa(0) As Single
  936.     ReDim vy1sa(0) As Single
  937.     ReDim ax1sa(0) As Single
  938.     ReDim ay1sa(0) As Single
  939.     FillStyle = 1 'transparent fill
  940.     j = SetPolyFillMode(hDC, 1)' reset to alternate fill mode
  941.     ClearScreen
  942.   End If
  943.   Else  ' put run code here
  944.     ' check if time to get a new color
  945.     If RepeatIndex > RepeatCount Then
  946.     'set fill color
  947.     i = Rnd * 255: If i > 255 Then i = 255
  948.     j = Rnd * 255: If j > 255 Then j = 255
  949.     k = Rnd * 255: If k > 255 Then k = 255
  950.     FillColor = GetNearestColor(hDC, RGB(i, j, k))
  951.     'set foreground color
  952.     i = Rnd * 255: If i > 255 Then i = 255
  953.     j = Rnd * 255: If j > 255 Then j = 255
  954.     k = Rnd * 255: If k > 255 Then k = 255
  955.     ForeColor = RGB(i, j, k)
  956.     RepeatIndex = 1
  957.     Else
  958.     RepeatIndex = RepeatIndex + 1
  959.     End If
  960.     'Draw polygon
  961.     j = Polygon(hDC, Points(0), Sets)
  962.     For j = 1 To Sets
  963.         'determine new acceleration
  964.         ax1sa(j) = Rnd - .5
  965.         ay1sa(j) = Rnd - .5
  966.         
  967.         'calculate new position
  968.         Points(j).x = Points(j).x + vx1sa(j)
  969.         Points(j).y = Points(j).y + vy1sa(j)
  970.         'calculate new velocity
  971.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  972.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  973.         'check if off screen
  974.         If (Points(j).x > ScaleWidth) Then
  975.         'change direction
  976.         vx1sa(j) = -Abs(vx1sa(j))
  977.         ElseIf (Points(j).x < 0) Then
  978.         'change direction
  979.         vx1sa(j) = Abs(vx1sa(j))
  980.         End If
  981.         If (Points(j).y > ScaleHeight) Then
  982.         'change direction
  983.         vy1sa(j) = -Abs(vy1sa(j))
  984.         ElseIf (Points(j).y < 0) Then
  985.         'change direction
  986.         vy1sa(j) = Abs(vy1sa(j))
  987.         End If
  988.     Next j
  989.     End If
  990. End Sub
  991. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  992.     Static KeyState As String * 257
  993.     Dim LongChar As Long
  994.     Dim KeyAscii As Integer
  995.     Static temp$    ' Collects characters each time key is pressed.
  996.     If Passwd = "" Then
  997.     LogFile ("KeyDown, Terminating"), 0
  998.     EndScrnSaveForm         ' End screen blanking
  999.     Else
  1000.     'refresh system modal in case another process
  1001.     'has grabbed it
  1002.     If TestMode = 0 Then
  1003.         ZOrder 0' make sure form is still on top
  1004.         i = SetSysModalWindow(hWnd)
  1005.     End If
  1006.     'refresh password box
  1007.     PasswordLabel.Visible = False
  1008.     PasswordLabel.Visible = True
  1009.     'convert key to ascii
  1010.     'GetKeyboardStateBystring (KeyState)' get kb state
  1011.     'i = ToAsciiBystring(KeyCode, 0, KeyState, LongChar, 0)
  1012.     'KeyAscii = LongChar Mod 256
  1013.     KeyAscii = MapVirtualKey(KeyCode, 2) ' convert virtual key code to ascii
  1014.     LogFile ("KeyDown, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received, translated to '" + Chr$(KeyAscii) + "' (" + Str$(KeyAscii) + ")"), 0
  1015.     KeyCode = 0' clear key
  1016.     'parse key into password
  1017.     If KeyAscii = 13 Then       ' ENTER key pressed.
  1018.        KeyAscii = 0            ' Prevents Beep after ENTER Key.
  1019.        If temp$ = Passwd Then
  1020.          LogFile ("Password entered, Terminating"), 0
  1021.          EndScrnSaveForm          ' End screen blanking
  1022.        Else
  1023.          temp$ = ""
  1024.          LogFile ("Invalid Password entered, Continuing"), 0
  1025.          PasswordLabel.Caption = "Password Invalid  "
  1026.          Beep  ' Signal user that password failed.
  1027.          Exit Sub
  1028.        End If
  1029.     ElseIf KeyAscii = 8 Then    ' Backspace key pressed.
  1030.        KeyAscii = 0            'character is not passed on
  1031.        If temp$ <> "" Then 'only delete if not empty
  1032.          temp$ = Left$(temp$, Len(temp$) - 1) ' Remove one char.
  1033.        Else
  1034.          Beep
  1035.        End If
  1036.     ElseIf Len(temp$) = NUMCHARS Then      ' Limit size of password.
  1037.        KeyAscii = 0
  1038.        Beep                    ' Signal user that field is full.
  1039.     ElseIf KeyAscii < 32 Then  ' ignore control keys
  1040.        KeyAscii = 0            ' character is not passed on
  1041.     Else 'normal character that we can recognize?
  1042.        temp$ = temp$ + UCase$(Chr$(KeyAscii))    ' Add a character.
  1043.        KeyAscii = 0            'character is not passed on
  1044.     End If
  1045.     PasswordLabel.Caption = "Password>" + String$(Len(temp$), "*")
  1046.     End If
  1047. End Sub
  1048. Sub Form_KeyPress (KeyAscii As Integer)
  1049.     If Passwd <> "" Then
  1050.     'refresh system modal in case another process
  1051.     'has grabbed it
  1052.     If TestMode = 0 Then
  1053.        ZOrder 0' make sure form is still on top
  1054.        i = SetSysModalWindow(hWnd)
  1055.     End If
  1056.        'refresh password box
  1057.        PasswordLabel.Visible = False
  1058.        PasswordLabel.Visible = True
  1059.        LogFile ("KeyPress, '" + Chr$(KeyAscii) + "' received, code(" + Str$(KeyAscii) + ")"), 0
  1060.        KeyAscii = 0 ' trap characters
  1061.     Else
  1062.     LogFile ("KeyPress, Terminating"), 0
  1063.     EndScrnSaveForm            ' End screen blanking
  1064.     End If
  1065. End Sub
  1066. Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
  1067. LogFile ("KeyUp, (" + Str$(KeyCode) + ", " + Str$(Shift) + ") received"), 0
  1068. End Sub
  1069. Sub Form_Load ()
  1070.     ' stretch to full screen
  1071.     Move 0, 0, screen.Width, screen.Height
  1072.     TotalNumColors = GetNumberOfColors()'read number colors display can handle
  1073.     LogFile "Display supports " + Str$(TotalNumColors) + " colors", 0
  1074.     KeyPreview = True 'form takes priority on keys
  1075.     'set system modal
  1076.     If TestMode = 0 Then
  1077.       ZOrder 0' make sure form is still on top
  1078.       i = SetSysModalWindow(hWnd) 'make sure can't CTL-ALT-DEL out
  1079.     End If
  1080.     'make mouse invisible
  1081.     If TestMode = 0 Then
  1082.       HideMouse
  1083.     End If
  1084.     'tell windows to disable screen savers
  1085.     i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, False, 0, 0)
  1086.     DrawWidth = 1
  1087.     Randomize
  1088.     MaxPlotType = 21
  1089.     ReadPriorities ' call each Plot type to get its priority
  1090.     ' Initialize variables now
  1091.     'set plot type
  1092.     If StartSaver = 0 Then
  1093.       PlotType = MaxPlotType * Rnd
  1094.     Else
  1095.       PlotType = StartSaver
  1096.     End If
  1097.     If PlotType > MaxPlotType Then PlotType = 1
  1098.     LogFile ("First Saver is " + Str$(PlotType)), 1
  1099.     PlotInit = False
  1100.     PlotEnd = False
  1101.     TimeInterval = 0
  1102.     MaxTime = MaxChangeMinutes * 60 + Timer ' calculate time in seconds
  1103.     'set tick rate
  1104.     Tick.Interval = 50
  1105.     Repeats = 1 ' number of drawings to make before returning
  1106.     Tick.Enabled = True
  1107. End Sub
  1108. Sub Form_MouseMove (Button As Integer, Shift As Integer, x As Single, y As Single)
  1109.     If IsEmpty(MouseX) Or IsEmpty(MouseY) Then
  1110.     MouseX = x
  1111.     MouseY = y
  1112.     LogFile ("First Mouse Movement (" + Str$(x) + "," + Str$(y) + ")"), 0
  1113.     End If
  1114.     '
  1115.     ' Only unblank the screen if the mouse moves quickly
  1116.     ' enough (more than 2 pixels at one time.
  1117.     '
  1118.     If Abs(MouseX - x) > 2 Or Abs(MouseY - y) > 2 Then
  1119.        
  1120.       If Passwd = "" Then ' only exit if no password
  1121.      LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Terminating"), 0
  1122.      LogFile ("Old Pos (" + Str$(MouseX) + "," + Str$(MouseY) + "), Terminating"), 0
  1123.      EndScrnSaveForm          ' End screen blanking
  1124.       Else
  1125.     'refresh system modal in case another process
  1126.     'has grabbed it
  1127.     If TestMode = 0 Then
  1128.         i = SetSysModalWindow(hWnd)
  1129.     End If
  1130.     PasswordLabel.Visible = False
  1131.     PasswordLabel.Visible = True
  1132.       End If
  1133.     End If
  1134.     LogFile ("Mouse Movement (" + Str$(x) + "," + Str$(y) + "), Continuing"), 0
  1135.     MouseX = x                   ' Remember last position
  1136.     MouseY = y
  1137. End Sub
  1138. Sub Form_Paint ()
  1139.     ' stretch to full screen
  1140.     Move 0, 0, screen.Width, screen.Height
  1141. End Sub
  1142. Function GetBrightNonGray () As Long
  1143. ' this function is needed because in 256 color mode
  1144. ' many random colors get mapped to grays
  1145.   Dim i As Long, j As Long, k As Long
  1146.   Dim NewColor As Long
  1147.     i = Rnd * 255: If i > 255 Then i = 255
  1148.     j = Rnd * 255: If j > 255 Then j = 255
  1149.     k = Rnd * 255: If k > 255 Then k = 255
  1150.     'LogFile ("GetBrightNonGray testing color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1151.     'get nearest colors
  1152.     NewColor = GetNearestColor(hDC, RGB(i, j, k))
  1153.     i = NewColor And &HFF
  1154.     j = NewColor \ &H100 And &HFF
  1155.     k = NewColor \ &H10000 And &HFF
  1156.     'LogFile ("GetBrightNonGray nearest color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1157.     'make sure color is sufficiently bright, and not too gray
  1158.     Loop Until ((i * i + j * j + k * k) > MinColor) And ((Abs(i - j) > MinDiff) Or (Abs(j - k) > MinDiff))
  1159.   'LogFile ("GetBrightNonGray using color (" + Str$(i) + "," + Str$(j) + "," + Str$(k) + ")")
  1160.   GetBrightNonGray = NewColor
  1161. End Function
  1162. Function GetNumberOfColors () As Single
  1163.   Dim i As Integer, j As Integer, k As Integer
  1164.   ' get bits per pixel per plane
  1165.   i = GetDeviceCaps(hDC, BITSPIXEL)
  1166.   ' get number of planes
  1167.   j = GetDeviceCaps(hDC, PLANES)
  1168.   ' get total bits per pixel
  1169.   k = i * j
  1170.   GetNumberOfColors = 2# ^ k
  1171. End Function
  1172. Function GetSize (FileName$) As Integer
  1173.     Dim InLine$
  1174.     Dim Loaded As Integer
  1175.     Open FileName$ For Binary As #1
  1176.     '*****************************************************
  1177.     'read header
  1178.     InLine$ = Input$(26, 1)
  1179.     If Asc(Mid$(InLine$, 1, 1)) <> &H42 Then GoTo errorexit
  1180.     If Asc(Mid$(InLine$, 2, 1)) <> &H4D Then GoTo errorexit
  1181.     PicWidth = Asc(Mid$(InLine$, 19, 1)) + Asc(Mid$(InLine$, 20, 1)) * 256
  1182.     PicHeight = Asc(Mid$(InLine$, 23, 1)) + Asc(Mid$(InLine$, 24, 1)) * 256
  1183.     'Debug.Print SWidth, SHeight
  1184.     Close #1
  1185.     Loaded = 1 'flag good read
  1186.     GoTo regexit
  1187. errorexit: Loaded = 0
  1188. regexit: ' no error exit
  1189.     GetSize = Loaded'return read state
  1190. End Function
  1191. Sub Kalied ()
  1192.   ' have a line and its mirror images trace across the
  1193.   ' screen with multiple previous copies following
  1194.   ' it
  1195.   Dim xRadius As Integer, yRadius As Integer
  1196.   Static OldWidth As Integer, OldHeight As Integer
  1197.   Static OldLeft As Integer, OldTop As Integer
  1198.   Static Discontinuous As Integer
  1199.   ' if first time then initialize
  1200.   If PlotInit = False Then
  1201.    'see if we need to reset changes made from previous init
  1202.    If PlotEnd = False Then
  1203.     'check if saver is permitted to run
  1204.     If CheckIfValidSaver(0) = 0 Then
  1205.       Exit Sub
  1206.     End If
  1207.     PlotInit = True
  1208.     Cls
  1209.     ForeColor = QBColor(15)
  1210.     If Rnd > .5 Then
  1211.       Discontinuous = False
  1212.     Else
  1213.       Discontinuous = True
  1214.     End If
  1215.     'select mirroring method
  1216.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1217.     'Set array size and clear the elements
  1218.     ReDim x1a(MaxLines) As Integer
  1219.     ReDim x2a(MaxLines) As Integer
  1220.     ReDim y1a(MaxLines) As Integer
  1221.     ReDim y2a(MaxLines) As Integer
  1222.     Pointer = 1     ' start with array element 1
  1223.     ' set index to count number of times to repeat color
  1224.     '   to past maxvalue so that it will be recalculated
  1225.     RepeatIndex = MaxLines + 1
  1226.     'save old
  1227.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1228.     OldLeft = Scaleleft: OldTop = Scaletop
  1229.     'change scaleso they are symetrical:
  1230.     ScaleHeight = ScaleWidth
  1231.     Scaleleft = -ScaleHeight / 2
  1232.     Scaletop = Scaleleft
  1233.     'Calculate velocity limits
  1234.     MaxSpeedX = ScaleWidth * 15! / 800
  1235.     MaxSpeedY = ScaleWidth * 15! / 600
  1236.     'determine initial position of line
  1237.     x1 = (Rnd - .5) * ScaleWidth
  1238.     x2 = (Rnd - .5) * ScaleWidth
  1239.     y1 = (Rnd - .5) * ScaleHeight
  1240.     y2 = (Rnd - .5) * ScaleHeight
  1241.     'set initial velocity
  1242.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1243.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1244.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1245.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1246.     'set initial acceleration
  1247.     ax1 = 0
  1248.     ax2 = 0
  1249.     ay1 = 0
  1250.     ay2 = 0
  1251.     'find background color
  1252.     m = QBColor(0)
  1253.     'set tick rate
  1254.     Tick.Interval = 50
  1255.   Else 'reset changes done by previous init
  1256.     'reset tick rate
  1257.     Tick.Interval = 50
  1258.     'zero array sizes
  1259.     ReDim x1a(0) As Integer
  1260.     ReDim x2a(0) As Integer
  1261.     ReDim y1a(0) As Integer
  1262.     ReDim y2a(0) As Integer
  1263.       'reset screen dimensions
  1264.       ScaleWidth = OldWidth
  1265.       ScaleHeight = OldHeight
  1266.       Scaleleft = OldLeft
  1267.       Scaletop = OldTop
  1268.     ClearScreen
  1269.   End If
  1270.   Else  ' put run code here
  1271.     ' check if time to get a new color
  1272.     If RepeatIndex > RepeatCount Then
  1273.     ' get color
  1274.     l = GetBrightNonGray()
  1275.     If Discontinuous = True Then
  1276.       'determine new position of line
  1277.       x1 = (Rnd - .5) * ScaleWidth
  1278.       x2 = (Rnd - .5) * ScaleWidth
  1279.       y1 = (Rnd - .5) * ScaleHeight
  1280.       y2 = (Rnd - .5) * ScaleHeight
  1281.       'set new velocity
  1282.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1283.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1284.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1285.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1286.       'clear acceleration
  1287.       ax1 = 0
  1288.       ax2 = 0
  1289.       ay1 = 0
  1290.       ay2 = 0
  1291.     End If
  1292.     RepeatIndex = 1
  1293.     Else
  1294.     RepeatIndex = RepeatIndex + 1
  1295.     End If
  1296.     'Delete original Lines
  1297.     KaliedPlot Mirror, x1a(Pointer), y1a(Pointer), x2a(Pointer), y2a(Pointer), m
  1298.     'Save New Lines
  1299.     x1a(Pointer) = x1
  1300.     x2a(Pointer) = x2
  1301.     y1a(Pointer) = y1
  1302.     y2a(Pointer) = y2
  1303.     DoEvents
  1304.     'Draw New Lines
  1305.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1306.     'Move pointer to next item
  1307.     Pointer = Pointer + 1
  1308.     If Pointer > MaxLines Then
  1309.         Pointer = 1
  1310.     End If
  1311.     'determine new acceleration
  1312.     ax1 = Rnd - .5
  1313.     ax2 = Rnd - .5
  1314.     ay1 = Rnd - .5
  1315.     ay2 = Rnd - .5
  1316.     'calculate new position
  1317.     x1 = x1 + vx1
  1318.     x2 = x2 + vx2
  1319.     y1 = y1 + vy1
  1320.     y2 = y2 + vy2
  1321.     'calculate new velocity
  1322.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1323.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1324.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1325.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1326.     'check if off screen
  1327.     If (x1 > -Scaleleft) Then
  1328.         'change direction
  1329.         vx1 = -Abs(vx1)
  1330.     ElseIf (x1 < Scaleleft) Then
  1331.         'change direction
  1332.         vx1 = Abs(vx1)
  1333.     End If
  1334.     If (y1 > -Scaletop) Then
  1335.         'change direction
  1336.         vy1 = -Abs(vy1)
  1337.     ElseIf (y1 < Scaletop) Then
  1338.         'change direction
  1339.         vy1 = Abs(vy1)
  1340.     End If
  1341.     If (x2 > -Scaleleft) Then
  1342.         'change direction
  1343.         vx2 = -Abs(vx2)
  1344.     ElseIf (x2 < Scaleleft) Then
  1345.         'change direction
  1346.         vx2 = Abs(vx2)
  1347.     End If
  1348.     If (y2 > -Scaletop) Then
  1349.         'change direction
  1350.         vy2 = -Abs(vy2)
  1351.     ElseIf (y2 < Scaletop) Then
  1352.         'change direction
  1353.         vy2 = Abs(vy2)
  1354.     End If
  1355.     End If
  1356. End Sub
  1357. Sub Kalied2 ()
  1358.   ' have a line and its mirror images trace across the
  1359.   ' screen with all the previous copies left on the screen
  1360.   ' until the maximum is reached and the screen cleared
  1361.   Dim xRadius As Integer, yRadius As Integer
  1362.   Static OldWidth As Integer, OldHeight As Integer
  1363.   Static OldLeft As Integer, OldTop As Integer
  1364.   Static Discontinuous As Integer
  1365.   ' if first time then initialize
  1366.   If PlotInit = False Then
  1367.     'see if we need to reset changes made from previous init
  1368.     If PlotEnd = True Then
  1369.       ScaleWidth = OldWidth
  1370.       ScaleHeight = OldHeight
  1371.       Scaleleft = OldLeft
  1372.       Scaletop = OldTop
  1373.       ClearScreen
  1374.       Exit Sub
  1375.     End If
  1376.     'check if saver is permitted to run
  1377.     If CheckIfValidSaver(0) = 0 Then
  1378.       Exit Sub
  1379.     End If
  1380.     PlotInit = True
  1381.     Cls
  1382.     ForeColor = QBColor(15)
  1383.     If Rnd > .5 Then
  1384.       Discontinuous = False
  1385.     Else
  1386.       Discontinuous = True
  1387.     End If
  1388.     'select mirroring method
  1389.     Mirror = Rnd * HighMirror + 1: If Mirror > HighMirror Then Mirror = 1
  1390.     Pointer = 1     ' set lines on screen to one
  1391.     ' set index to count number of times to repeat color
  1392.     '   to past maxvalue so that it will be recalculated
  1393.     RepeatIndex = MaxLines + 1
  1394.     'save old
  1395.     OldWidth = ScaleWidth: OldHeight = ScaleHeight
  1396.     OldLeft = Scaleleft: OldTop = Scaletop
  1397.     'change scaleso they are symetrical:
  1398.     ScaleHeight = ScaleWidth
  1399.     Scaleleft = -ScaleHeight / 2
  1400.     Scaletop = Scaleleft
  1401.     'determine initial position of line
  1402.     x1 = (Rnd - .5) * ScaleWidth
  1403.     x2 = (Rnd - .5) * ScaleWidth
  1404.     y1 = (Rnd - .5) * ScaleHeight
  1405.     y2 = (Rnd - .5) * ScaleHeight
  1406.     'set initial velocity
  1407.     vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1408.     vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1409.     vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1410.     vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1411.     'set initial acceleration
  1412.     ax1 = 0
  1413.     ax2 = 0
  1414.     ay1 = 0
  1415.     ay2 = 0
  1416.     'find background color
  1417.     m = QBColor(0)
  1418.     'Calculate velocity limits
  1419.     MaxSpeedX = ScaleWidth * 15! / 800
  1420.     MaxSpeedY = ScaleWidth * 15! / 600
  1421.   Else  ' put run code here
  1422.     ' check if time to get a new color
  1423.     If RepeatIndex > RepeatCount Then
  1424.     ' get color
  1425.     l = GetBrightNonGray()
  1426.     If Discontinuous = True Then
  1427.       'determine new position of line
  1428.       x1 = (Rnd - .5) * ScaleWidth
  1429.       x2 = (Rnd - .5) * ScaleWidth
  1430.       y1 = (Rnd - .5) * ScaleHeight
  1431.       y2 = (Rnd - .5) * ScaleHeight
  1432.       'set new velocity
  1433.       vx1 = (Rnd - .5) * 2 * MaxSpeedX
  1434.       vx2 = (Rnd - .5) * 2 * MaxSpeedX
  1435.       vy1 = (Rnd - .5) * 2 * MaxSpeedY
  1436.       vy2 = (Rnd - .5) * 2 * MaxSpeedY
  1437.       'clear acceleration
  1438.       ax1 = 0
  1439.       ax2 = 0
  1440.       ay1 = 0
  1441.       ay2 = 0
  1442.     End If
  1443.     RepeatIndex = 1
  1444.     Else
  1445.     RepeatIndex = RepeatIndex + 1
  1446.     End If
  1447.     'Draw New Lines
  1448.     KaliedPlot Mirror, x1, y1, x2, y2, l
  1449.     ' count total lines on screen
  1450.     Pointer = Pointer + 1
  1451.     If Pointer > MaxCums Then
  1452.         'when maximum reached then clear
  1453.         Cls
  1454.         Pointer = 1
  1455.     End If
  1456.     'determine new acceleration
  1457.     ax1 = Rnd - .5
  1458.     ax2 = Rnd - .5
  1459.     ay1 = Rnd - .5
  1460.     ay2 = Rnd - .5
  1461.     'calculate new position
  1462.     x1 = x1 + vx1
  1463.     x2 = x2 + vx2
  1464.     y1 = y1 + vy1
  1465.     y2 = y2 + vy2
  1466.     'calculate new velocity
  1467.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  1468.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  1469.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  1470.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  1471.     'check if off screen
  1472.     If (x1 > -Scaleleft) Then
  1473.         'change direction
  1474.         vx1 = -Abs(vx1)
  1475.     ElseIf (x1 < Scaleleft) Then
  1476.         'change direction
  1477.         vx1 = Abs(vx1)
  1478.     End If
  1479.     If (y1 > -Scaletop) Then
  1480.         'change direction
  1481.         vy1 = -Abs(vy1)
  1482.     ElseIf (y1 < Scaletop) Then
  1483.         'change direction
  1484.         vy1 = Abs(vy1)
  1485.     End If
  1486.     If (x2 > -Scaleleft) Then
  1487.         'change direction
  1488.         vx2 = -Abs(vx2)
  1489.     ElseIf (x2 < Scaleleft) Then
  1490.         'change direction
  1491.         vx2 = Abs(vx2)
  1492.     End If
  1493.     If (y2 > -Scaletop) Then
  1494.         'change direction
  1495.         vy2 = -Abs(vy2)
  1496.     ElseIf (y2 < Scaletop) Then
  1497.         'change direction
  1498.         vy2 = Abs(vy2)
  1499.     End If
  1500.     End If
  1501. End Sub
  1502. Sub KaliedPlot (MirrorMode As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Color As Long)
  1503. 'warning -- recursive subroutine
  1504.   Dim xm1 As Integer, ym1 As Integer, xm2 As Integer, ym2 As Integer
  1505.     Select Case MirrorMode
  1506.     Case 1: 'mirror on x and y axis
  1507.         Line (x1, y1)-(x2, y2), Color
  1508.         Line (-x1, y1)-(-x2, y2), Color
  1509.         Line (x1, -y1)-(x2, -y2), Color
  1510.         Line (-x1, -y1)-(-x2, -y2), Color
  1511.     Case 2: 'mirror on Y axis
  1512.         Line (x1, y1)-(x2, y2), Color
  1513.         Line (-x1, y1)-(-x2, y2), Color
  1514.     Case 3: 'mirror around center point
  1515.         Line (x1, y1)-(x2, y2), Color
  1516.         Line (-x1, -y1)-(-x2, -y2), Color
  1517.     Case 4: 'mirror around center point and diagonally
  1518.         Line (x1, y1)-(x2, y2), Color
  1519.         Line (-x1, -y1)-(-x2, -y2), Color
  1520.         'mirror diagonally
  1521.         xm1 = y1
  1522.         ym1 = x1
  1523.         xm2 = y2
  1524.         ym2 = x2
  1525.         Line (-xm1, ym1)-(-xm2, ym2), Color
  1526.         Line (xm1, -ym1)-(xm2, -ym2), Color
  1527.     Case 5: 'mirror on x and y axis and diagonally
  1528.         Line (x1, y1)-(x2, y2), Color
  1529.         Line (-x1, y1)-(-x2, y2), Color
  1530.         Line (x1, -y1)-(x2, -y2), Color
  1531.         Line (-x1, -y1)-(-x2, -y2), Color
  1532.         'mirror diagonally
  1533.         xm1 = y1
  1534.         ym1 = x1
  1535.         xm2 = y2
  1536.         ym2 = x2
  1537.         Line (xm1, ym1)-(xm2, ym2), Color
  1538.         Line (-xm1, ym1)-(-xm2, ym2), Color
  1539.         Line (xm1, -ym1)-(xm2, -ym2), Color
  1540.         Line (-xm1, -ym1)-(-xm2, -ym2), Color
  1541.     Case 6: 'mirror around center point and diagonally
  1542.         'and then shift 45 degrees and repeat
  1543.         KaliedPlot 4, x1, y1, x2, y2, Color
  1544.         'shift 45 degrees, formula
  1545.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1546.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1547.         xm1 = x1 * Cos45 - y1 * Sin45
  1548.         ym1 = y1 * Cos45 + x1 * Sin45
  1549.         xm2 = x2 * Cos45 - y2 * Sin45
  1550.         ym2 = y2 * Cos45 + x2 * Sin45
  1551.         KaliedPlot 4, xm1, ym1, xm2, ym2, Color
  1552.     Case 7: 'mirror on x and y axis and diagonally
  1553.         'and then shift 45 degrees and repeat
  1554.         KaliedPlot 5, x1, y1, x2, y2, Color
  1555.         'shift 45 degrees, formula
  1556.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1557.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1558.         xm1 = x1 * Cos45 - y1 * Sin45
  1559.         ym1 = y1 * Cos45 + x1 * Sin45
  1560.         xm2 = x2 * Cos45 - y2 * Sin45
  1561.         ym2 = y2 * Cos45 + x2 * Sin45
  1562.         KaliedPlot 5, xm1, ym1, xm2, ym2, Color
  1563.     Case 8: 'mirror around center point and diagonally
  1564.         'and then shift 45 degrees and repeat
  1565.         'and then shift 22.5 and repeat the above
  1566.         KaliedPlot 6, x1, y1, x2, y2, Color
  1567.         'shift 22.5 degrees, formula
  1568.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1569.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1570.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  1571.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  1572.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  1573.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  1574.         KaliedPlot 6, xm1, ym1, xm2, ym2, Color
  1575.     Case 9: 'mirror on x and y axis and diagonally
  1576.         'and then shift 45 degrees and repeat
  1577.         'and then shift 22.5 and repeat the above
  1578.         KaliedPlot 7, x1, y1, x2, y2, Color
  1579.         'shift 22.5 degrees, formula
  1580.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1581.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1582.         xm1 = x1 * Cos22_5 - y1 * Sin22_5
  1583.         ym1 = y1 * Cos22_5 + x1 * Sin22_5
  1584.         xm2 = x2 * Cos22_5 - y2 * Sin22_5
  1585.         ym2 = y2 * Cos22_5 + x2 * Sin22_5
  1586.         KaliedPlot 7, xm1, ym1, xm2, ym2, Color
  1587.     Case 10: 'mirror around center point and diagonally
  1588.         'and then shift 45 degrees and repeat
  1589.         'and then shift 22.5 and repeat the above
  1590.         'and then shift 11.25 and repeat the above
  1591.         KaliedPlot 8, x1, y1, x2, y2, Color
  1592.         'shift 22.5 degrees, formula
  1593.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1594.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1595.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  1596.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  1597.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  1598.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  1599.         KaliedPlot 8, xm1, ym1, xm2, ym2, Color
  1600.     Case 11: 'mirror on x and y axis and diagonally
  1601.         'and then shift 45 degrees and repeat
  1602.         'and then shift 22.5 and repeat the above
  1603.         'and then shift 11.25 and repeat the above
  1604.         KaliedPlot 9, x1, y1, x2, y2, Color
  1605.         'shift 22.5 degrees, formula
  1606.         'r*sin(a+b) = y*cos(b) + x*sin(b)
  1607.         'r*cos(a+b) = x*cos(b) - y*sin(b)
  1608.         xm1 = x1 * Cos11_25 - y1 * Sin11_25
  1609.         ym1 = y1 * Cos11_25 + x1 * Sin11_25
  1610.         xm2 = x2 * Cos11_25 - y2 * Sin11_25
  1611.         ym2 = y2 * Cos11_25 + x2 * Sin11_25
  1612.         KaliedPlot 9, xm1, ym1, xm2, ym2, Color
  1613.     Case Else: MirrorMode = 1' if invalid value set, then change
  1614.     End Select
  1615. End Sub
  1616. Sub Lines ()
  1617.   ' have a random number of lines trace across the
  1618.   ' screen with multiple previous copies following
  1619.   ' them
  1620.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  1621.   Dim il As Long, jl As Long, kl As Long
  1622.   Static Sets As Integer
  1623.   ' if first time then initialize
  1624.   If PlotInit = False Then
  1625.    'see if we need to reset changes made from previous init
  1626.    If PlotEnd = False Then
  1627.     'check if saver is permitted to run
  1628.     If CheckIfValidSaver(0) = 0 Then
  1629.       Exit Sub
  1630.     End If
  1631.     PlotInit = True
  1632.     Cls
  1633.     ForeColor = QBColor(15)
  1634.     'set number of sets between 1 and 4
  1635.     Sets = Rnd * 3 + 1
  1636.     'Set array size and clear the elements
  1637.     ReDim x1da(MaxLines, Sets) As Integer
  1638.     ReDim x2da(MaxLines, Sets) As Integer
  1639.     ReDim y1da(MaxLines, Sets) As Integer
  1640.     ReDim y2da(MaxLines, Sets) As Integer
  1641.     ReDim x1sa(Sets) As Single
  1642.     ReDim x2sa(Sets) As Single
  1643.     ReDim y1sa(Sets) As Single
  1644.     ReDim y2sa(Sets) As Single
  1645.     ReDim vx1sa(Sets) As Single
  1646.     ReDim vx2sa(Sets) As Single
  1647.     ReDim vy1sa(Sets) As Single
  1648.     ReDim vy2sa(Sets) As Single
  1649.     ReDim ax1sa(Sets) As Single
  1650.     ReDim ax2sa(Sets) As Single
  1651.     ReDim ay1sa(Sets) As Single
  1652.     ReDim ay2sa(Sets) As Single
  1653.     ReDim Colors(Sets) As Long
  1654.     Pointer = 1     ' start with array element 1
  1655.     ' set index to count number of times to repeat color
  1656.     '   to past maxvalue so that it will be recalculated
  1657.     RepeatIndex = MaxLines + 1
  1658.     For j = 1 To Sets
  1659.     'determine initial position of line
  1660.     x1sa(j) = Rnd * ScaleWidth
  1661.     x2sa(j) = Rnd * ScaleWidth
  1662.     y1sa(j) = Rnd * ScaleHeight
  1663.     y2sa(j) = Rnd * ScaleHeight
  1664.     Next j
  1665.     'find background color
  1666.     m = QBColor(0)
  1667.     'Calculate velocity limits
  1668.     MaxSpeedX = ScaleWidth * 15! / 800
  1669.     MaxSpeedY = ScaleWidth * 15! / 600
  1670.   Else 'reset changes done by previous init
  1671.     'Set array size and clear the elements
  1672.     ReDim x1da(0, 0) As Integer
  1673.     ReDim x2da(0, 0) As Integer
  1674.     ReDim y1da(0, 0) As Integer
  1675.     ReDim y2da(0, 0) As Integer
  1676.     ReDim x1sa(0) As Single
  1677.     ReDim x2sa(0) As Single
  1678.     ReDim y1sa(0) As Single
  1679.     ReDim y2sa(0) As Single
  1680.     ReDim vx1sa(0) As Single
  1681.     ReDim vx2sa(0) As Single
  1682.     ReDim vy1sa(0) As Single
  1683.     ReDim vy2sa(0) As Single
  1684.     ReDim ax1sa(0) As Single
  1685.     ReDim ax2sa(0) As Single
  1686.     ReDim ay1sa(0) As Single
  1687.     ReDim ay2sa(0) As Single
  1688.     ReDim Colors(0) As Long
  1689.     ClearScreen
  1690.   End If
  1691.   Else  ' put run code here
  1692.     ' check if time to get a new color
  1693.     If RepeatIndex > RepeatCount Then
  1694.     ' get colors
  1695.     For ii = 1 To Sets
  1696.       Colors(ii) = GetBrightNonGray()
  1697.     Next ii
  1698.     RepeatIndex = 1
  1699.     Else
  1700.     RepeatIndex = RepeatIndex + 1
  1701.     End If
  1702.     'Delete original Lines
  1703.     For j = 1 To Sets
  1704.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), m
  1705.     Next j
  1706.     For j = 1 To Sets
  1707.         'Save New Lines
  1708.         x1da(Pointer, j) = x1sa(j)
  1709.         x2da(Pointer, j) = x2sa(j)
  1710.         y1da(Pointer, j) = y1sa(j)
  1711.         y2da(Pointer, j) = y2sa(j)
  1712.         'Draw new Line
  1713.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x2da(Pointer, j), y2da(Pointer, j)), Colors(j)
  1714.     Next j
  1715.     'Move pointer to next item
  1716.     Pointer = Pointer + 1
  1717.     If Pointer > MaxLines Then
  1718.         Pointer = 1
  1719.     End If
  1720.     For j = 1 To Sets
  1721.         'determine new acceleration
  1722.         ax1sa(j) = Rnd - .5
  1723.         ax2sa(j) = Rnd - .5
  1724.         ay1sa(j) = Rnd - .5
  1725.         ay2sa(j) = Rnd - .5
  1726.         'calculate new position
  1727.         x1sa(j) = x1sa(j) + vx1sa(j)
  1728.         x2sa(j) = x2sa(j) + vx2sa(j)
  1729.         y1sa(j) = y1sa(j) + vy1sa(j)
  1730.         y2sa(j) = y2sa(j) + vy2sa(j)
  1731.         'calculate new velocity
  1732.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  1733.         vx2sa(j) = (vx2sa(j) + ax2sa(j)): If Abs(vx2sa(j)) > MaxSpeedX Then vx2sa(j) = 0: ax2sa(j) = 0
  1734.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  1735.         vy2sa(j) = (vy2sa(j) + ay2sa(j)): If Abs(vy2sa(j)) > MaxSpeedY Then vy2sa(j) = 0: ay2sa(j) = 0
  1736.         'check if off screen
  1737.         If (x1sa(j) > ScaleWidth) Then
  1738.         'change direction
  1739.         vx1sa(j) = -Abs(vx1sa(j))
  1740.         ElseIf (x1sa(j) < 0) Then
  1741.         'change direction
  1742.         vx1sa(j) = Abs(vx1sa(j))
  1743.         End If
  1744.         If (y1sa(j) > ScaleHeight) Then
  1745.         'change direction
  1746.         vy1sa(j) = -Abs(vy1sa(j))
  1747.         ElseIf (y1sa(j) < 0) Then
  1748.         'change direction
  1749.         vy1sa(j) = Abs(vy1sa(j))
  1750.         End If
  1751.         If (x2sa(j) > ScaleWidth) Then
  1752.         'change direction
  1753.         vx2sa(j) = -Abs(vx2sa(j))
  1754.         ElseIf (x2sa(j) < 0) Then
  1755.         'change direction
  1756.         vx2sa(j) = Abs(vx2sa(j))
  1757.         End If
  1758.         If (y2sa(j) > ScaleHeight) Then
  1759.         'change direction
  1760.         vy2sa(j) = -Abs(vy2sa(j))
  1761.         ElseIf (y2sa(j) < 0) Then
  1762.         'change direction
  1763.         vy2sa(j) = Abs(vy2sa(j))
  1764.         End If
  1765.     Next j
  1766.   End If
  1767. End Sub
  1768. Function LoadSlide (File As String, ShowPic As Integer) As Integer
  1769.  'loads picture to screen, if gif file extension, then
  1770.  'save to dib bitmap, returns zero on failure
  1771.   Dim RetVal As Integer, i As Integer, l As Long
  1772.   Dim Header As Long, DataBits As Long
  1773.   Dim TempName As String
  1774.   RetVal = 1
  1775.   If InStr(UCase$(File), ".GIF") = 0 Then
  1776.     ' if not gif file, then bitmap
  1777.     If ShowPic Then
  1778.       On Error GoTo 116
  1779.       picture = LoadPicture(File)
  1780.       On Error GoTo 0
  1781.     End If
  1782.     'get dimensions of bitmap
  1783.     If GetSize(File) = 0 Then RetVal = 0
  1784.   Else ' convert gif to DIB
  1785.     l = ManyGifLoad(File, PicWidth, PicHeight)'load gif
  1786.     If l <= 0 Then
  1787.       LogFile "Could not read GIF file " + File, 1
  1788.       RetVal = 0
  1789.     Else
  1790.       'where to store converted file
  1791.       TempName = RTrim$(BitmapsDir) + "\tmprary.dib"
  1792.       i = ManyDIBWrite(TempName)
  1793.       If i <> 0 Then 'check for error
  1794.     LogFile "Could not write GIF file " + TempName, 1
  1795.     RetVal = 0
  1796.       Else
  1797.     If ShowPic Then
  1798.       On Error GoTo 116
  1799.       picture = LoadPicture(TempName)
  1800.       On Error GoTo 0
  1801.     End If
  1802.       End If
  1803.     End If
  1804.   End If
  1805.   LoadSlide = RetVal
  1806.   Exit Function
  1807. 116 'could not load file, out of memory?
  1808.   On Error GoTo 0
  1809.   RetVal = 0
  1810.   LogFile ("Could not load file " + File), 1
  1811.   Resume Next
  1812. End Function
  1813. Function LoadSlideAndTile (File As String) As Integer
  1814. ' returns zero on error
  1815.   Dim i As Integer, RetVal As Integer
  1816.   RetVal = 1
  1817.     If File = "" Then
  1818.       RetVal = 0
  1819.     Else
  1820.       i = LoadSlide(File, 1)'put file on display
  1821.       If i = 0 Then 'check if could not load
  1822.     RetVal = 0
  1823.       Else
  1824.     Replicate
  1825.       End If
  1826.     End If
  1827.   LoadSlideAndTile = i
  1828. End Function
  1829. Sub MultiSpiros ()
  1830.   'Do spirograph like figures
  1831.   'reserve memory
  1832.   Const Deg2Pi = PI / 180
  1833.   Static MaxRad As Integer'maximum radius for circles
  1834.   Const MaxNodes = 35'maximum number of nodes on spiro
  1835.   Dim Nodes As Integer
  1836.   Const MaxRpts = 7'max times to go around circle
  1837.   Dim Rpts As Integer
  1838.   Const PlotPoints = 1'number of points to plot each time
  1839.   Const ClearCount = 3'number on screen before clearing
  1840.   Static PlotAngleIncr As Single
  1841.   Static PlotEndAngle As Single
  1842.   Static PlotAngle As Single
  1843.   Static SinIncr As Single
  1844.   Static SinAngle As Single
  1845.   Static Xcenter As Integer
  1846.   Static Ycenter As Integer
  1847.   Static Xincr As Integer
  1848.   Static Yincr As Integer
  1849.   Const MaxSpiro = 8' maximum number of simultaneous spiros
  1850.   Static SpiroCnt As Integer
  1851.   Static Rad1 As Integer
  1852.   Static Rad2 As Integer
  1853.   Dim r As Single
  1854.   Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
  1855.   Dim il As Long, jl As Long, kl As Long
  1856.   ' if first time then initialize
  1857.   If PlotInit = False Then
  1858.     'see if we need to reset changes made from previous init
  1859.     If PlotEnd = False Then
  1860.     'check if saver is permitted to run
  1861.     If CheckIfValidSaver(0) = 0 Then
  1862.       Exit Sub
  1863.     End If
  1864.       PlotInit = True
  1865.       ForeColor = RGB(255, 255, 255)
  1866.       BackColor = RGB(0, 0, 0)
  1867.       Cls
  1868.      'initialize variables used
  1869.      PlotEndAngle = 0
  1870.      PlotAngle = 10
  1871.      MaxRad = ScaleHeight / 3'maximum radius for circles
  1872.      Pointer = 0
  1873.     Else 'reset changes done by previous init
  1874.       DrawWidth = 1' use narrow line
  1875.       ClearScreen
  1876.     End If
  1877.   Else  ' put run code here
  1878.    Do
  1879.     ' check if time to do new spiro
  1880.     If PlotAngle > PlotEndAngle Then
  1881.     'set foreground color
  1882.     ForeColor = GetBrightNonGray()
  1883.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  1884.     Rpts = Rnd * MaxRpts + .5
  1885.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  1886.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  1887.     Nodes = Rnd * MaxNodes + .5
  1888.     SinIncr = PlotAngleIncr * Nodes / Rpts
  1889.     SinAngle = 0
  1890.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  1891.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  1892.     'get location of first
  1893.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  1894.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  1895.     'get location of last
  1896.     i = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  1897.     j = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  1898.     'get number
  1899.     SpiroCnt = (MaxSpiro - 2) * Rnd + 2' maximum number of simultaneous spiros
  1900.     'calculate increment
  1901.     Xincr = (i - Xcenter) / (SpiroCnt - 1)
  1902.     Yincr = (j - Ycenter) / (SpiroCnt - 1)
  1903.     DrawWidth = 1 + 2 * Rnd ' set line width
  1904.     GoSub 3000 'calculate x1 and y1
  1905.     Delay 2'pause before clearing screen
  1906.     End If
  1907.     For i = 1 To PlotPoints
  1908.       GoSub 3000 'calculate x1 and y1
  1909.       k = x1: l = y1: m = LastX: n = LastY
  1910.       'plot each spiro
  1911.       For j = 1 To SpiroCnt
  1912.     'draw line
  1913.     Line (m, n)-(k, l)
  1914.     'get location for next
  1915.     k = k + Xincr: l = l + Yincr
  1916.     m = m + Xincr: n = n + Yincr
  1917.       Next j
  1918.     Next i
  1919.     DoEvents
  1920.     CurrentTime = Timer
  1921.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  1922.    Loop
  1923.   End If
  1924.   Exit Sub
  1925. 3000 'calculate new point on screen
  1926.   LastX = x1: LastY = y1
  1927.   r = Rad1 + Rad2 * Sin(SinAngle)
  1928.   x1 = r * Cos(PlotAngle) + Xcenter
  1929.   y1 = r * Sin(PlotAngle) + Ycenter
  1930.   SinAngle = SinAngle + SinIncr
  1931.   PlotAngle = PlotAngle + PlotAngleIncr
  1932.   Return
  1933. End Sub
  1934. Sub NextSelection ()
  1935. Dim i As Integer
  1936. Dim Level As Single
  1937. If RandomFlag <> 0 Then
  1938.   ' pick a new selection but not the same as the last
  1939.     'i = Int(Rnd * MaxPlotType) + 1'choose next one at random
  1940.     Level = Rnd * TotalPriority' get random proportion of TP
  1941.     'now search array to see which saver this prop. falls into
  1942.     i = 1
  1943.     While (PriorityBreakPoints(i) <= Level)
  1944.       i = i + 1
  1945.     Wend
  1946.     'Debug.Print i, Level, TotalPriority
  1947.     If (i > MaxPlotType) Or (i < 1) Then i = PlotType'flag to try again
  1948.   Loop While (i = PlotType)
  1949.   PlotType = i
  1950.   PlotType = PlotType + 1
  1951. End If
  1952. LogFile ("Next Saver is" + Str$(PlotType)), 1
  1953. End Sub
  1954. Sub Patch ()
  1955.   ' copy blocks of original screen to random spots
  1956.   ' if first time then initialize
  1957.   If PlotInit = False Then
  1958.    'see if we need to reset changes made from previous init
  1959.    If PlotEnd = False Then
  1960.     'check if saver is permitted to run
  1961.     If CheckIfValidSaver(1) = 0 Then
  1962.       Exit Sub
  1963.     End If
  1964.     ' set tick rate down
  1965.     Tick.Interval = 250
  1966.     ' start with original screen
  1967.     picture = original.Image
  1968.     PlotInit = True
  1969.     i = Int(Rnd * 2#) 'if i=0 then alternate reverse copy
  1970.   Else 'reset changes done by previous init
  1971.     ClearScreen
  1972.     'reset tick rate
  1973.     Tick.Interval = 50
  1974.   End If
  1975.   Else  ' put run code here
  1976.     BoxHeight = Rnd * ScaleHeight / 2.5
  1977.     BoxWidth = Rnd * ScaleWidth / 2.5 * (8# / 6#)
  1978.     ' get random locations
  1979.     x1 = Rnd * ScaleWidth
  1980.     y1 = Rnd * ScaleHeight
  1981.     x2 = Rnd * ScaleWidth
  1982.     y2 = Rnd * ScaleHeight
  1983.     'make sure room in destination and source blocks
  1984.     If x1 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x1
  1985.     If x2 + BoxWidth > ScaleWidth Then BoxWidth = ScaleWidth - x2
  1986.     If y1 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y1
  1987.     If y2 + BoxHeight > ScaleHeight Then BoxHeight = ScaleHeight - y2
  1988.     'BitBlt Box from x2,y2 to x1,y1
  1989.     DC = original.hDC
  1990.     If i = 0 And Rnd < .5 Then
  1991.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &H330008 'not source copy
  1992.     Else
  1993.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, &HCC0020 'source copy
  1994.     End If
  1995.   End If
  1996. End Sub
  1997. Sub Polygons ()
  1998.   ' draw a randomly moving polygon on the screen
  1999.   ' with multiple previous copies following it
  2000.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2001.   Dim il As Long, jl As Long, kl As Long
  2002.   Static Sets As Integer
  2003.   ' if first time then initialize
  2004.   If PlotInit = False Then
  2005.     'see if we need to reset changes made from previous init
  2006.     If PlotEnd = False Then
  2007.     'check if saver is permitted to run
  2008.     If CheckIfValidSaver(0) = 0 Then
  2009.       Exit Sub
  2010.     End If
  2011.     PlotInit = True
  2012.     Cls
  2013.     ForeColor = QBColor(15)
  2014.     'set number of sets between 3 and 5
  2015.     Sets = Rnd * 2 + 3
  2016.     'Set array size and clear the elements
  2017.     ReDim x1da(MaxLines, Sets) As Integer
  2018.     ReDim y1da(MaxLines, Sets) As Integer
  2019.     ReDim x1sa(Sets) As Single
  2020.     ReDim y1sa(Sets) As Single
  2021.     ReDim vx1sa(Sets) As Single
  2022.     ReDim vy1sa(Sets) As Single
  2023.     ReDim ax1sa(Sets) As Single
  2024.     ReDim ay1sa(Sets) As Single
  2025.     Pointer = 1     ' start with array element 1
  2026.     ' set index to count number of times to repeat color
  2027.     '   to past maxvalue so that it will be recalculated
  2028.     RepeatIndex = MaxLines + 1
  2029.     For j = 1 To Sets
  2030.     'determine initial position of line
  2031.     x1sa(j) = Rnd * ScaleWidth
  2032.     y1sa(j) = Rnd * ScaleHeight
  2033.     Next j
  2034.     'find background color
  2035.     m = QBColor(0)
  2036.     'Calculate velocity limits
  2037.     MaxSpeedX = ScaleWidth * 15! / 800
  2038.     MaxSpeedY = ScaleWidth * 15! / 600
  2039.   Else 'reset changes done by previous init
  2040.     'Set array size and clear the elements
  2041.     ReDim x1da(0, 0) As Integer
  2042.     ReDim y1da(0, 0) As Integer
  2043.     ReDim x1sa(0) As Single
  2044.     ReDim y1sa(0) As Single
  2045.     ReDim vx1sa(0) As Single
  2046.     ReDim vy1sa(0) As Single
  2047.     ReDim ax1sa(0) As Single
  2048.     ReDim ay1sa(0) As Single
  2049.     ClearScreen
  2050.   End If
  2051.   Else  ' put run code here
  2052.     ' check if time to get a new color
  2053.     If RepeatIndex > RepeatCount Then
  2054.     ' get colors
  2055.     l = GetBrightNonGray()
  2056.     RepeatIndex = 1
  2057.     Else
  2058.     RepeatIndex = RepeatIndex + 1
  2059.     End If
  2060.     'Delete original Lines
  2061.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), m
  2062.     For j = 3 To Sets
  2063.         Line -(x1da(Pointer, j), y1da(Pointer, j)), m
  2064.     Next j
  2065.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), m
  2066.     For j = 1 To Sets
  2067.         'Save New Lines
  2068.         x1da(Pointer, j) = x1sa(j)
  2069.         y1da(Pointer, j) = y1sa(j)
  2070.     Next j
  2071.     'Draw New Lines
  2072.     Line (x1da(Pointer, 1), y1da(Pointer, 1))-(x1da(Pointer, 2), y1da(Pointer, 2)), l
  2073.     For j = 3 To Sets
  2074.         Line -(x1da(Pointer, j), y1da(Pointer, j)), l
  2075.     Next j
  2076.     Line -(x1da(Pointer, 1), y1da(Pointer, 1)), l
  2077.     'Move pointer to next item
  2078.     Pointer = Pointer + 1
  2079.     If Pointer > MaxLines Then
  2080.         Pointer = 1
  2081.     End If
  2082.     For j = 1 To Sets
  2083.         'determine new acceleration
  2084.         ax1sa(j) = Rnd - .5
  2085.         ay1sa(j) = Rnd - .5
  2086.         
  2087.         'calculate new position
  2088.         x1sa(j) = x1sa(j) + vx1sa(j)
  2089.         y1sa(j) = y1sa(j) + vy1sa(j)
  2090.         'calculate new velocity
  2091.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > MaxSpeedX Then vx1sa(j) = 0: ax1sa(j) = 0
  2092.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > MaxSpeedY Then vy1sa(j) = 0: ay1sa(j) = 0
  2093.         'check if off screen
  2094.         If (x1sa(j) > ScaleWidth) Then
  2095.         'change direction
  2096.         vx1sa(j) = -Abs(vx1sa(j))
  2097.         ElseIf (x1sa(j) < 0) Then
  2098.         'change direction
  2099.         vx1sa(j) = Abs(vx1sa(j))
  2100.         End If
  2101.         If (y1sa(j) > ScaleHeight) Then
  2102.         'change direction
  2103.         vy1sa(j) = -Abs(vy1sa(j))
  2104.         ElseIf (y1sa(j) < 0) Then
  2105.         'change direction
  2106.         vy1sa(j) = Abs(vy1sa(j))
  2107.         End If
  2108.     Next j
  2109.     End If
  2110. End Sub
  2111. Sub Puzzle ()
  2112.   'scramble screen by shifting one column or row at a time
  2113.   Dim tempx As Integer, tempy As Integer
  2114.   Dim x As Integer, y As Integer
  2115.   ' if first time then initialize
  2116.   If PlotInit = False Then
  2117.     'see if we need to reset changes made from previous init
  2118.     If PlotEnd = False Then
  2119.     'check if saver is permitted to run
  2120.     If CheckIfValidSaver(1) = 0 Then
  2121.       Exit Sub
  2122.     End If
  2123.     ' set tick rate down
  2124.     Tick.Interval = 1000
  2125.     ' start with original screen
  2126.     picture = original.Image
  2127.     'find background color
  2128.     m = QBColor(0)
  2129.     PlotInit = True
  2130.     Number = Rnd * 16 + 4
  2131.     'Number = 20
  2132.     BoxHeight = ScaleHeight / Number
  2133.     BoxWidth = ScaleWidth / Number
  2134.     'initialize blocks
  2135.     ReDim x1da(Number, Number) As Integer
  2136.     ReDim y1da(Number, Number) As Integer
  2137.     For x1 = 1 To Number
  2138.     For y1 = 1 To Number
  2139.         x1da(x1, y1) = (x1 - 1) * BoxWidth
  2140.         y1da(x1, y1) = (y1 - 1) * BoxHeight
  2141.     Next y1
  2142.     Next x1
  2143.   Else 'reset changes done by previous init
  2144.     ReDim x1da(0, 0) As Integer
  2145.     ReDim y1da(0, 0) As Integer
  2146.     'reset tick rate
  2147.     Tick.Interval = 50
  2148.     ClearScreen
  2149.   End If
  2150.   Else  ' put run code here
  2151.     If Int(Rnd * 2) = 1 Then 'shift column
  2152.     x1 = Rnd * Number + 1: If x1 > Number Then x1 = 1
  2153.     If Int(Rnd * 2) = 1 Then 'shift down
  2154.         tempx = x1da(x1, Number)
  2155.         tempy = y1da(x1, Number)
  2156.         For y1 = Number To 2 Step -1
  2157.         x1da(x1, y1) = x1da(x1, y1 - 1)
  2158.         y1da(x1, y1) = y1da(x1, y1 - 1)
  2159.         'BitBlt Box to x1,y1
  2160.         DC = original.hDC
  2161.         x = (x1 - 1) * BoxWidth
  2162.         y = (y1 - 1) * BoxHeight
  2163.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2164.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2165.         Next y1
  2166.         y1 = 1
  2167.         x1da(x1, y1) = tempx
  2168.         y1da(x1, y1) = tempy
  2169.         'BitBlt Box to x1,y1
  2170.         DC = original.hDC
  2171.         x = (x1 - 1) * BoxWidth
  2172.         y = (y1 - 1) * BoxHeight
  2173.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2174.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2175.     Else ' shift up
  2176.         tempx = x1da(x1, 1)
  2177.         tempy = y1da(x1, 1)
  2178.         For y1 = 1 To (Number - 1)
  2179.         x1da(x1, y1) = x1da(x1, y1 + 1)
  2180.         y1da(x1, y1) = y1da(x1, y1 + 1)
  2181.         'BitBlt Box to x1,y1
  2182.         DC = original.hDC
  2183.         x = (x1 - 1) * BoxWidth
  2184.         y = (y1 - 1) * BoxHeight
  2185.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2186.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2187.         
  2188.         Next y1
  2189.         y1 = Number
  2190.         x1da(x1, y1) = tempx
  2191.         y1da(x1, y1) = tempy
  2192.         'BitBlt Box to x1,y1
  2193.         DC = original.hDC
  2194.         x = (x1 - 1) * BoxWidth
  2195.         y = (y1 - 1) * BoxHeight
  2196.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2197.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2198.     End If
  2199.     Else ' shift row
  2200.     y1 = Rnd * Number + 1: If y1 > Number Then y1 = 1
  2201.     If Int(Rnd * 2) = 1 Then 'shift right
  2202.         tempx = x1da(Number, y1)
  2203.         tempy = y1da(Number, y1)
  2204.         For x1 = Number To 2 Step -1
  2205.         x1da(x1, y1) = x1da(x1 - 1, y1)
  2206.         y1da(x1, y1) = y1da(x1 - 1, y1)
  2207.         'BitBlt Box to x1,y1
  2208.         DC = original.hDC
  2209.         x = (x1 - 1) * BoxWidth
  2210.         y = (y1 - 1) * BoxHeight
  2211.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2212.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2213.         Next x1
  2214.         x1 = 1
  2215.         x1da(x1, y1) = tempx
  2216.         y1da(x1, y1) = tempy
  2217.         'BitBlt Box to x1,y1
  2218.         DC = original.hDC
  2219.         x = (x1 - 1) * BoxWidth
  2220.         y = (y1 - 1) * BoxHeight
  2221.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2222.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2223.     Else 'shift left
  2224.         tempx = x1da(1, y1)
  2225.         tempy = y1da(1, y1)
  2226.         For x1 = 1 To (Number - 1)
  2227.         x1da(x1, y1) = x1da(x1 + 1, y1)
  2228.         y1da(x1, y1) = y1da(x1 + 1, y1)
  2229.         'BitBlt Box to x1,y1
  2230.         DC = original.hDC
  2231.         x = (x1 - 1) * BoxWidth
  2232.         y = (y1 - 1) * BoxHeight
  2233.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2234.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2235.         Next x1
  2236.         x1 = Number
  2237.         x1da(x1, y1) = tempx
  2238.         y1da(x1, y1) = tempy
  2239.         'BitBlt Box to x1,y1
  2240.         DC = original.hDC
  2241.         x = (x1 - 1) * BoxWidth
  2242.         y = (y1 - 1) * BoxHeight
  2243.         BitBlt hDC, x, y, BoxWidth, BoxHeight, DC, x1da(x1, y1), y1da(x1, y1), &HCC0020
  2244.         Line (x, y)-Step(BoxWidth, BoxHeight), m, B
  2245.     End If
  2246.     End If
  2247.   End If
  2248. End Sub
  2249. Sub ReadPriorities ()
  2250.   Dim i As Integer, j As Integer
  2251.   Dim temp As String * 30, Out  As String
  2252.   Dim Priority As Single
  2253.   ReDim PriorityBreakPoints(MaxPlotType + 1) As Single
  2254.   ReDim Priorities(MaxPlotType) As Integer
  2255.   TotalPriority = 0
  2256.   For i = 1 To MaxPlotType
  2257.     j = GetPrivateProfileString(secName, PriorityBaseName + Int2Str(i), "1", temp, 28, iniName)
  2258.     Priority = Val(temp)
  2259.     Out = Out + Str$(Priority)
  2260.     If Priority < 0# Then Priority = 0#
  2261.     If Priority = 0# Then
  2262.       Priorities(i) = 0
  2263.     Else
  2264.       Priorities(i) = 1
  2265.     End If
  2266.     TotalPriority = TotalPriority + Priority
  2267.     PriorityBreakPoints(i) = TotalPriority
  2268.   Next
  2269.   LogFile "Priorites set to " + Out, 0
  2270.   PriorityBreakPoints(MaxPlotType + 1) = TotalPriority + 3.402E+38
  2271. End Sub
  2272. Sub Replicate ()
  2273.   Dim x As Integer, y As Integer, x1 As Integer, y1 As Integer
  2274.   DoEvents
  2275.   DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  2276.   'limit sizes
  2277.   If PicWidth > ScrnWidth Then PicWidth = ScrnWidth
  2278.   If PicHeight > ScrnHeight Then PicHeight = ScrnHeight
  2279.   If (PicWidth < ScrnWidth) Or (PicHeight < ScrnHeight) Then
  2280.     'need to center picture
  2281.     'first backup picture
  2282.     BitBlt original.hDC, 0, 0, PicWidth, PicHeight, DC, 0, 0, &HCC0020
  2283.     'clear original
  2284.     'Picture = LoadPicture()
  2285.     ' now copy back centered
  2286.     x = ScrnWidth / 2 - PicWidth / 2
  2287.     y = ScrnHeight / 2 - PicHeight / 2
  2288.     BitBlt hDC, x, y, PicWidth, PicHeight, original.hDC, 0, 0, &HCC0020
  2289.   End If
  2290.   If (PicWidth < ScrnWidth) Then 'fill row
  2291.     '1st copy left
  2292.     x1 = x
  2293.     While x1 > 0
  2294.       BitBlt hDC, x1 - PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  2295.       x1 = x1 - PicWidth
  2296.     Wend
  2297.     'next copy right
  2298.     x1 = x
  2299.     While x1 < ScrnWidth
  2300.       BitBlt hDC, x1 + PicWidth, 0, PicWidth, ScrnHeight, hDC, x, 0, &HCC0020
  2301.       x1 = x1 + PicWidth
  2302.     Wend
  2303.   End If
  2304.   If (PicHeight < ScrnHeight) Then
  2305.     '1st copy up
  2306.     y1 = y
  2307.     While y1 > 0
  2308.       BitBlt hDC, 0, y1 - PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  2309.       y1 = y1 - PicHeight
  2310.     Wend
  2311.     'next copy down
  2312.     y1 = y
  2313.     While y1 < ScrnHeight
  2314.       BitBlt hDC, 0, y1 + PicHeight, ScrnWidth, PicHeight, hDC, 0, y, &HCC0020
  2315.       y1 = y1 + PicHeight
  2316.     Wend
  2317.   End If
  2318.   i = DeleteDC(DC)
  2319. End Sub
  2320. Sub Roll ()
  2321.   ' the display rolls both horizontally and vertically
  2322.   Dim v As Integer
  2323.   ' if first time then initialize
  2324.   If PlotInit = False Then
  2325.     'see if we need to reset changes made from previous init
  2326.     If PlotEnd = False Then
  2327.     'check if saver is permitted to run
  2328.     If CheckIfValidSaver(1) = 0 Then
  2329.       Exit Sub
  2330.     End If
  2331.     ' start with original screen
  2332.     picture = original.Image
  2333.     PlotInit = True
  2334.     'Calculate velocity limits
  2335.     MaxSpeedX = ScaleWidth * 15! / 800
  2336.     MaxSpeedY = ScaleWidth * 15! / 600
  2337.     ' initial velocities
  2338.     vy1 = 0: vx1 = 0
  2339.     ' initial offset
  2340.     x1 = 0: y1 = 0
  2341.     Direction = Rnd * 2: If Direction > 1 Then Direction = 0
  2342.   Else 'reset changes done by previous init
  2343.     ClearScreen
  2344.   End If
  2345.   Else  ' put run code here
  2346.     DC = original.hDC
  2347.     If Direction Then
  2348.     ' do vertical scroll
  2349.     BitBlt hDC, 0, y1, ScaleWidth, ScaleHeight - y1, DC, 0, 0, &HCC0020
  2350.     BitBlt hDC, 0, 0, ScaleWidth, y1, DC, 0, ScaleHeight - y1, &HCC0020
  2351.     Else
  2352.     ' do horizontal scroll
  2353.     BitBlt hDC, x1, 0, ScaleWidth - x1, ScaleHeight, DC, 0, 0, &HCC0020
  2354.     BitBlt hDC, 0, 0, x1, ScaleHeight, DC, ScaleWidth - x1, 0, &HCC0020
  2355.     End If
  2356.     'determine new acceleration
  2357.     ax1 = Rnd - .5
  2358.     ay1 = Rnd - .5
  2359.         
  2360.     'calculate new velocity
  2361.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  2362.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  2363.     'find new roll amount
  2364.     x1 = x1 + vx1
  2365.     If x1 > ScaleWidth Then
  2366.     x1 = x1 - ScaleWidth
  2367.     Else
  2368.     If x1 < 0 Then
  2369.         x1 = x1 + ScaleWidth
  2370.     End If
  2371.     End If
  2372.         
  2373.     y1 = y1 + vy1
  2374.     If y1 > ScaleHeight Then
  2375.     y1 = y1 - ScaleHeight
  2376.     Else
  2377.     If y1 < 0 Then
  2378.         y1 = y1 + ScaleHeight
  2379.     End If
  2380.     End If
  2381.         
  2382.   End If
  2383. End Sub
  2384. Sub RunSelection ()
  2385.     ' execute the appropriate selection
  2386.     Select Case PlotType
  2387.     Case 1: Squiggles
  2388.     Case 2: Kalied2
  2389.     Case 3: Polygons
  2390.     Case 4: Circles
  2391.     Case 5: Kalied
  2392.     Case 6: Lines
  2393.     Case 7: Roll
  2394.     Case 8: FilledCircles
  2395.     Case 9: Patch
  2396.     Case 10: Spiro
  2397.     Case 11: Scrape
  2398.     Case 12: Stretch
  2399.     Case 13: Dribble
  2400.     Case 14: Drop
  2401.     Case 15: Slides
  2402.     Case 16: FilledPolygons
  2403.     Case 17: MultiSpiros
  2404.     Case 18: Puzzle
  2405.     Case 19: ShootHoles
  2406.     Case 20: CyclePalette
  2407.     Case 21: Confetti
  2408.     Case Else: PlotType = 1
  2409.            RunSelection ' try again
  2410.     End Select
  2411. End Sub
  2412. Sub Scrape ()
  2413.   Static smear As Integer
  2414.   ' bitblt's with various patterns, dragging them
  2415.   ' across the screen randomly
  2416.   ' if first time then initialize
  2417.   If PlotInit = False Then
  2418.     'see if we need to reset changes made from previous init
  2419.     If PlotEnd = False Then
  2420.     'check if saver is permitted to run
  2421.     If CheckIfValidSaver(1) = 0 Then
  2422.       Exit Sub
  2423.     End If
  2424.     ' start with original screen
  2425.     picture = original.Image
  2426.     PlotInit = True
  2427.     'determine initial position of line
  2428.     x1 = Rnd * ScaleWidth
  2429.     y1 = Rnd * ScaleHeight
  2430.     'Calculate velocity limits
  2431.     MaxSpeedX = ScaleWidth * 15! / 800
  2432.     MaxSpeedY = ScaleWidth * 15! / 600
  2433.     BoxHeight = 400 * Rnd ^ 3 + 20
  2434.     BoxWidth = (400 * Rnd ^ 3 + 20) * (8# / 6#)
  2435.     ' zero initial velocity
  2436.     vx1 = 0: vy1 = 0
  2437.     'default for smear
  2438.     smear = False
  2439.     ' choose scrape type at random
  2440.     i = Rnd * 14 + 1
  2441.     'i = 12
  2442.     Select Case i
  2443.     Case 1: Pattern = &H42 'Black Out
  2444.         Locked = True
  2445.     Case 2: Pattern = &HFF0062 'White Out
  2446.         Locked = True
  2447.     Case 3: Pattern = &HBB0226 'MergePaint
  2448.         Locked = False
  2449.     Case 4: Pattern = &H330008 'Not source copy
  2450.         Locked = True
  2451.     Case 5: Pattern = &H330008 'Not source copy
  2452.         Locked = False
  2453.     Case 6: Pattern = &H330008 'Not source copy
  2454.         Locked = False
  2455.         picture = LoadPicture() ' start with blank screen
  2456.     Case 7: Pattern = &H330008 'Not source copy
  2457.         smear = True
  2458.         'set random source location
  2459.         x2 = Rnd * (ScaleWidth - BoxWidth)
  2460.         y2 = Rnd * (ScaleHeight - BoxHeight)
  2461.     Case 8: Pattern = &H660046 'source invert
  2462.         Locked = True
  2463.     Case 9: Pattern = &H8800C6 'source and
  2464.         Locked = False
  2465.     Case 10: Pattern = &HEE0086 'source paint (or)
  2466.         Locked = False
  2467.     Case 11: Pattern = &H550009 'Invert Destination
  2468.         Locked = True
  2469.     Case 12: Pattern = &HCC0020 'Source Copy
  2470.         Locked = False
  2471.     Case 13: Pattern = &HCC0020 'Source Copy
  2472.         Locked = True
  2473.         picture = LoadPicture() ' start with blank screen
  2474.     Case Else: Pattern = &HCC0020 'Source Copy
  2475.         smear = True
  2476.         'set random source location
  2477.         x2 = Rnd * (ScaleWidth - BoxWidth)
  2478.         y2 = Rnd * (ScaleHeight - BoxHeight)
  2479.     End Select
  2480.   Else 'reset changes done by previous init
  2481.     ClearScreen
  2482.   End If
  2483.   Else  ' put run code here
  2484.     If smear Then
  2485.       'do nothing
  2486.     ' do locking if necessary
  2487.     ElseIf Locked Then
  2488.         x2 = x1: y2 = y1
  2489.     Else 'do offset
  2490.         x2 = x1 + BoxWidth: If x2 + BoxWidth > ScaleWidth Then x2 = 0
  2491.         y2 = y1 + BoxHeight: If y2 + BoxHeight > ScaleHeight Then y2 = 0
  2492.     End If
  2493.     'BitBlt Box at x1,y1
  2494.     DC = original.hDC
  2495.     BitBlt hDC, x1, y1, BoxWidth, BoxHeight, DC, x2, y2, Pattern
  2496.     'determine new acceleration
  2497.     ax1 = Rnd - .5
  2498.     ay1 = Rnd - .5
  2499.         
  2500.     'calculate new position
  2501.     x1 = x1 + vx1
  2502.     y1 = y1 + vy1
  2503.         
  2504.     'calculate new velocity
  2505.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  2506.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  2507.         
  2508.     'check if off screen
  2509.     If (x1 > ScaleWidth - BoxWidth) Then
  2510.         'change direction
  2511.         vx1 = -Abs(vx1)
  2512.     ElseIf (x1 < 0) Then
  2513.         'change direction
  2514.         vx1 = Abs(vx1)
  2515.     End If
  2516.     If (y1 > ScaleHeight - BoxHeight) Then
  2517.         'change direction
  2518.         vy1 = -Abs(vy1)
  2519.     ElseIf (y1 < 0) Then
  2520.         'change direction
  2521.         vy1 = Abs(vy1)
  2522.     End If
  2523.   End If
  2524. End Sub
  2525. Sub SetWindow2DIBPalette (State As Integer)
  2526.   Dim i As Integer, j As Integer, k As Integer, l As Integer
  2527.   Dim usepal%
  2528.   'read dib palette into logical palette for cycling
  2529.   ManyLoadLogPal Pal, 0, 256, State
  2530.   usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  2531.   'this has problems:
  2532.   'i = SetPaletteEntries%(usepal%, 0, PALENTRIES, Pal.palPalEntry(0))
  2533.   'Pal.palNumEntries
  2534.   'try to set windows palette to logical palette using clipboard
  2535.   If PaletteHandle <> 0 Then
  2536.     i = DeleteObject(PaletteHandle)
  2537.   End If
  2538.   PaletteHandle = CreatePalette(Pal)
  2539.   j = OpenClipboard(hWnd)
  2540.   k = SetClipboardData(CF_PALETTE, PaletteHandle)
  2541.   l = CloseClipboard()
  2542.   picture = Clipboard.GetData(CF_PALETTE)
  2543.   Clipboard.Clear
  2544. End Sub
  2545. Sub ShootHoles ()
  2546.   ' shoots small holes approximately at the same place
  2547.   Dim i As Integer, j As Integer, k As Integer
  2548.   Dim r As Long, x As Long, y As Long
  2549.   Static Radius As Integer, HoleSize  As Integer
  2550.   Dim temp As Single
  2551.   Const pi2 = PI * 2
  2552.   ' if first time then initialize
  2553.   If PlotInit = False Then
  2554.     'see if we need to reset changes made from previous init
  2555.     If PlotEnd = False Then
  2556.     'check if saver is permitted to run
  2557.     If CheckIfValidSaver(1) = 0 Then
  2558.       Exit Sub
  2559.     End If
  2560.     ' start with original screen
  2561.     picture = original.Image
  2562.     PlotInit = True
  2563.     'determine initial position of shot
  2564.     x1 = Rnd * ScaleWidth
  2565.     y1 = Rnd * ScaleHeight
  2566.     'determine maximum radius of shot
  2567.     Radius = (ScaleHeight - 100) * Rnd + 100
  2568.     'set size of holes
  2569.     HoleSize = 20 * Rnd ^ 2 + 2
  2570.     RunMode = Int(Rnd * 3)'choose color mode to show
  2571.     FillStyle = 0 'solid fill
  2572.     If RunMode > 0 Then ' if random color then use larger spots
  2573.     i = Rnd * 255: If i > 255 Then i = 255
  2574.     j = Rnd * 255: If j > 255 Then j = 255
  2575.     k = Rnd * 255: If k > 255 Then k = 255
  2576.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  2577.     FillColor = ForeColor
  2578.     Else
  2579.       ForeColor = RGB(0, 0, 0)' use black box
  2580.       FillColor = RGB(0, 0, 0) 'set black fill
  2581.     End If
  2582.   Else 'reset changes done by previous init
  2583.     ClearScreen
  2584.     FillStyle = 1 'transparent fill
  2585.   End If
  2586. Else  ' put run code here
  2587.     If RunMode > 1 Then ' if random color then use larger spots
  2588.     i = Rnd * 255: If i > 255 Then i = 255
  2589.     j = Rnd * 255: If j > 255 Then j = 255
  2590.     k = Rnd * 255: If k > 255 Then k = 255
  2591.     ForeColor = GetNearestColor(hDC, RGB(i, j, k))
  2592.     FillColor = ForeColor
  2593.     End If
  2594.     'get distance from center
  2595.     r = Rnd * Radius
  2596.     'get random angle
  2597.     temp = Rnd * pi2
  2598.     'get x portion
  2599.     x = r * Cos(temp)
  2600.     'get y portion
  2601.     y = r * Sin(temp)
  2602.     ' randomly change sign of x offset
  2603.     If Rnd > .5 Then
  2604.       x = -x
  2605.     End If
  2606.     ' randomly change sign of y offset
  2607.     If Rnd > .5 Then
  2608.       y = -y
  2609.     End If
  2610.     ' put random hole here
  2611.     Circle (x1 + x, y1 + y), HoleSize, , , , 1
  2612.   End If
  2613. End Sub
  2614. Sub ShowPal (palette As LOGPALETTE)
  2615. 'displays the current palette
  2616.     Dim usepal%
  2617.     ' Get a handle to the control's palette
  2618.     usepal% = SendMessageByNum(hWnd, VBM_GETPALETTE, 0, 0)
  2619.     AnimatePalette usepal%, 0, PALENTRIES, palette.palPalEntry(0)
  2620. End Sub
  2621. Sub Slides ()
  2622.   'cycle between different bitmaps
  2623.   Dim j As Integer
  2624.   Static File As String
  2625.   Static OldTime As Long
  2626.   Static running As Integer
  2627.   Dim CurTime As Long
  2628.   Dim FileName As String
  2629.   ' if first time then initialize
  2630.   If PlotInit = False Then
  2631.    'see if we need to reset changes made from previous init
  2632.    If PlotEnd = False Then
  2633.     'check if saver is permitted to run
  2634.     If CheckIfValidSaver(1) = 0 Then
  2635.       Exit Sub
  2636.     End If
  2637.     File = GetNextFile(BitmapsDir, 1, "gif", "bmp", "")
  2638.     ' find file
  2639.     j = Rnd * 50 ' pick file at random
  2640.     For i = 1 To j
  2641.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  2642.     Next i
  2643.     i = LoadSlideAndTile(File)
  2644.     If i = 0 Then 'check if could not load
  2645.       NextSelection 'jump to next since there are no bitmap files in directory
  2646.       Exit Sub
  2647.     End If
  2648.     OldTime = Timer
  2649.     running = False
  2650.     PlotInit = True
  2651.   Else 'reset changes done by previous init
  2652.     ' save screen in place of original for latter use
  2653.     ' we do this because on palette based systems
  2654.     ' the slide procedure messes up the color
  2655.     ' palette and the Clipboard.setData 9 and
  2656.     ' Clipboard.GetData(9) sequence does not restore
  2657.     ' it, so we just use the new picture with the
  2658.     ' new palette from now on
  2659.     DC = CreateDC("DISPLAY", 0&, 0&, 0&)
  2660.     BitBlt original.hDC, 0, 0, ScrnWidth, ScrnHeight, DC, 0, 0, &HCC0020
  2661.     i = DeleteDC(DC)
  2662.     i = ManyDibFree() 'free memory used for dib
  2663.     If i <> 0 Then
  2664.       LogFile "Could not free memory", 1
  2665.     End If
  2666.     ClearScreen
  2667.   End If
  2668. Else  ' put run code here
  2669.     If running Then Exit Sub ' no recursive calls
  2670.     If File = "" Then Exit Sub
  2671.     CurTime = Timer
  2672.     If (CurTime >= OldTime) And ((OldTime + BmpSeconds) > CurTime) Then Exit Sub
  2673.     OldTime = Timer
  2674.     running = True
  2675.     j = Rnd * 20
  2676.     For i = 1 To j
  2677.       File = GetNextFile(BitmapsDir, 0, "gif", "bmp", "")' get next file
  2678.     Next i
  2679.     i = LoadSlideAndTile(File)
  2680.     If i = 0 Then 'check if could not load
  2681.       NextSelection 'jump to next since there are no bitmap files in directory
  2682.       Exit Sub
  2683.     End If
  2684.   End If
  2685.   running = False
  2686.   Exit Sub
  2687. 115 'directory path does not exist
  2688.   On Error GoTo 0
  2689.   LogFile ("Could not find file " + FileName), 1
  2690.   Resume 117
  2691. 117 NextSelection 'jump to next since there are no bitmap files in directory
  2692.   Exit Sub
  2693. End Sub
  2694. Sub Spiro ()
  2695.   'Do spirograph like figures
  2696.   'reserve memory
  2697.   Const Deg2Pi = PI / 180
  2698.   Static MaxRad As Integer'maximum radius for circles
  2699.   Const MaxNodes = 35'maximum number of nodes on spiro
  2700.   Dim Nodes As Integer
  2701.   Const MaxRpts = 7'max times to go around circle
  2702.   Dim Rpts As Integer
  2703.   Const PlotPoints = 1'number of points to plot each time
  2704.   Const ClearCount = 3'number on screen before clearing
  2705.   Static PlotAngleIncr As Single
  2706.   Static PlotEndAngle As Single
  2707.   Static PlotAngle As Single
  2708.   Static SinIncr As Single
  2709.   Static SinAngle As Single
  2710.   Static Xcenter As Integer
  2711.   Static Ycenter As Integer
  2712.   Static Rad1 As Integer
  2713.   Static Rad2 As Integer
  2714.   Dim r As Single
  2715.   Dim l As Integer
  2716.   ' if first time then initialize
  2717.   If PlotInit = False Then
  2718.    'see if we need to reset changes made from previous init
  2719.    If PlotEnd = False Then
  2720.     'check if saver is permitted to run
  2721.     If CheckIfValidSaver(0) = 0 Then
  2722.       Exit Sub
  2723.     End If
  2724.       PlotInit = True
  2725.       ForeColor = RGB(255, 255, 255)
  2726.       BackColor = RGB(0, 0, 0)
  2727.       Cls
  2728.      'initialize variables used
  2729.      PlotEndAngle = 0
  2730.      PlotAngle = 10
  2731.      MaxRad = ScaleHeight / 3'maximum radius for circles
  2732.      Pointer = 0
  2733.     Else 'reset changes done by previous init
  2734.       DrawWidth = 1' use narrow line
  2735.       ClearScreen
  2736.     End If
  2737.   Else  ' put run code here
  2738.    Do
  2739.     ' check if time to do new spiro
  2740.     If PlotAngle > PlotEndAngle Then
  2741.     'set foreground color
  2742.     ForeColor = GetBrightNonGray()
  2743.     PlotAngle = Rnd * 180 * Deg2Pi'initial offset
  2744.     Rpts = Rnd * MaxRpts + .5
  2745.     PlotAngleIncr = .125 * Rpts * Deg2Pi
  2746.     PlotEndAngle = 360 * Rpts * Deg2Pi + PlotAngle + PlotAngleIncr
  2747.     Nodes = Rnd * MaxNodes + .5
  2748.     SinIncr = PlotAngleIncr * Nodes / Rpts
  2749.     SinAngle = 0
  2750.     Rad1 = MaxRad * Rnd + ScaleHeight / 80
  2751.     Rad2 = MaxRad * Rnd + ScaleHeight / 80
  2752.     Xcenter = Rnd * ScaleWidth * 3 / 4 + ScaleWidth / 8
  2753.     Ycenter = Rnd * ScaleHeight * 3 / 4 + ScaleHeight / 8
  2754.     DrawWidth = 1 + 2 * Rnd' use narrow line
  2755.     GoSub 2000 'calculate x1 and y1
  2756.     Pointer = Pointer + 1
  2757.     If Pointer >= ClearCount Then
  2758.       Delay 3'pause before clearing screen
  2759.       Cls
  2760.       Pointer = 0
  2761.     End If
  2762.     currentx = x1
  2763.     currenty = y1
  2764.     End If
  2765.     For l = 1 To PlotPoints
  2766.       GoSub 2000 'calculate x1 and y1
  2767.       'draw line
  2768.       'Line (LastX, LastY)-(x1, y1)
  2769.       Line -(x1, y1)
  2770.     Next l
  2771.     DoEvents
  2772.     CurrentTime = Timer
  2773.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then Exit Sub
  2774.    Loop
  2775.   End If
  2776.   Exit Sub
  2777. 2000 'calculate new point on screen
  2778.   'LastX = x1: LastY = y1
  2779.   r = Rad1 + Rad2 * Sin(SinAngle)
  2780.   x1 = r * Cos(PlotAngle) + Xcenter
  2781.   y1 = r * Sin(PlotAngle) + Ycenter
  2782.   SinAngle = SinAngle + SinIncr
  2783.   PlotAngle = PlotAngle + PlotAngleIncr
  2784.   Return
  2785. End Sub
  2786. Sub Squiggles ()
  2787.   ' draw multiple squiggles on the screen.
  2788.   ' each squiggle is assign a random color at the
  2789.   ' start, then the head travels randomly and the
  2790.   ' tail is erased
  2791.   Dim i As Integer, j As Integer, k As Integer, ii As Integer, n As Integer
  2792.   Dim il As Long, jl As Long, kl As Long
  2793.   Static SquigNumb As Integer
  2794.   Static SquigLen As Integer
  2795.   Static EndPointer As Integer, StartPointer As Integer
  2796.   ' if first time then initialize
  2797.   If PlotInit = False Then
  2798.    'see if we need to reset changes made from previous init
  2799.    If PlotEnd = False Then
  2800.     'check if saver is permitted to run
  2801.     If CheckIfValidSaver(0) = 0 Then
  2802.       Exit Sub
  2803.     End If
  2804.     PlotInit = True
  2805.     Cls
  2806.     ForeColor = QBColor(15)
  2807.     SquigNumb = Rnd * 10 + 10
  2808.     SquigLen = Rnd * 100 + 50
  2809.     'Allocate Memory
  2810.     ReDim x1da(SquigLen, SquigNumb)  As Integer
  2811.     ReDim y1da(SquigLen, SquigNumb)  As Integer
  2812.     ReDim x1sa(SquigNumb) As Single
  2813.     ReDim y1sa(SquigNumb) As Single
  2814.     ReDim vx1sa(SquigNumb) As Single
  2815.     ReDim vy1sa(SquigNumb) As Single
  2816.     ReDim ax1sa(SquigNumb) As Single
  2817.     ReDim ay1sa(SquigNumb) As Single
  2818.     ReDim Colors(SquigNumb) As Long
  2819.     Pointer = 1
  2820.     'Print "Clearing Array"
  2821.     For j = 1 To SquigNumb
  2822.     'determine initial position of line
  2823.     x1sa(j) = Rnd * ScaleWidth
  2824.     y1sa(j) = Rnd * ScaleHeight
  2825.     For i = 1 To SquigLen
  2826.         x1da(i, j) = x1sa(j)
  2827.         y1da(i, j) = y1sa(j)
  2828.     Next i
  2829.     Next j
  2830.     'find background color
  2831.     m = QBColor(0)
  2832.     ' get colors
  2833.     For ii = 1 To SquigNumb
  2834.     Colors(ii) = GetBrightNonGray()
  2835.     Next ii
  2836.     'Calculate velocity limits
  2837.     MaxSpeedX = ScaleWidth * 15! / 800
  2838.     MaxSpeedY = ScaleWidth * 15! / 600
  2839.   Else 'reset changes done by previous init
  2840.     ReDim x1da(0, 0)  As Integer
  2841.     ReDim y1da(0, 0)  As Integer
  2842.     ReDim x1sa(0) As Single
  2843.     ReDim y1sa(0) As Single
  2844.     ReDim vx1sa(0) As Single
  2845.     ReDim vy1sa(0) As Single
  2846.     ReDim ax1sa(0) As Single
  2847.     ReDim ay1sa(0) As Single
  2848.     ReDim Colors(0) As Long
  2849.     ClearScreen
  2850.   End If
  2851.   Else  ' put run code here
  2852.     'find where tail line went to
  2853.     If Pointer < SquigLen Then
  2854.         EndPointer = Pointer + 1
  2855.     Else
  2856.         EndPointer = 1
  2857.     End If
  2858.     'find where new line goes
  2859.     If Pointer > 1 Then
  2860.         StartPointer = Pointer - 1
  2861.     Else
  2862.         StartPointer = SquigLen
  2863.     End If
  2864.     If Rnd < .1 Then 'change a color 10% of the time
  2865.       ii = Int(Rnd * SquigNumb + 1)' get random squiggle to change
  2866.       If ii > SquigNumb Then ii = 1
  2867.       Colors(ii) = GetBrightNonGray()
  2868.     End If
  2869.     For j = 1 To SquigNumb
  2870.         'Erase tails of squigles
  2871.         Line (x1da(Pointer, j), y1da(Pointer, j))-(x1da(EndPointer, j), y1da(EndPointer, j)), m
  2872.         'Save new points
  2873.         x1da(Pointer, j) = x1sa(j)
  2874.         y1da(Pointer, j) = y1sa(j)
  2875.         'Draw front of Squigles
  2876.         Line (x1da(StartPointer, j), y1da(StartPointer, j))-(x1da(Pointer, j), y1da(Pointer, j)), Colors(j)
  2877.     Next j
  2878.     'Move pointer to next item
  2879.     Pointer = Pointer + 1
  2880.     If Pointer > SquigLen Then
  2881.         Pointer = 1
  2882.     End If
  2883.     For j = 1 To SquigNumb
  2884.         'determine new acceleration
  2885.         ax1sa(j) = Rnd * 4 - 2
  2886.         ay1sa(j) = Rnd * 4 - 2
  2887.         'calculate new position
  2888.         x1sa(j) = x1sa(j) + vx1sa(j)
  2889.         y1sa(j) = y1sa(j) + vy1sa(j)
  2890.         'calculate new velocity
  2891.         vx1sa(j) = (vx1sa(j) + ax1sa(j)): If Abs(vx1sa(j)) > 20 Then vx1sa(j) = 0: ax1sa(j) = 0
  2892.         vy1sa(j) = (vy1sa(j) + ay1sa(j)): If Abs(vy1sa(j)) > 20 Then vy1sa(j) = 0: ay1sa(j) = 0
  2893.         'check if off screen
  2894.         If (x1sa(j) > ScaleWidth) Then
  2895.         x1sa(j) = ScaleWidth
  2896.         'change direction
  2897.         vx1sa(j) = -Abs(vx1sa(j))
  2898.         ElseIf (x1sa(j) < 0) Then
  2899.         x1sa(j) = 0
  2900.         'change direction
  2901.         vx1sa(j) = Abs(vx1sa(j))
  2902.         End If
  2903.         If (y1sa(j) > ScaleHeight) Then
  2904.         y1sa(j) = ScaleHeight
  2905.         'change direction
  2906.         vy1sa(j) = -Abs(vy1sa(j))
  2907.         ElseIf (y1sa(j) < 0) Then
  2908.         y1sa(j) = 0
  2909.         'change direction
  2910.         vy1sa(j) = Abs(vy1sa(j))
  2911.         End If
  2912.     Next j
  2913.   End If
  2914. End Sub
  2915. Sub Stretch ()
  2916.     Dim x As Integer, y As Integer
  2917.     Static ShadowDC As Integer
  2918.     Static oldBM As Integer
  2919.   ' does a StretchBlt from a random box within the Original
  2920.   ' image and then displays it on the screen
  2921.   ' if first time then initialize
  2922.   If PlotInit = False Then
  2923.     'see if we need to reset changes made from previous init
  2924.     If PlotEnd = False Then
  2925.     'check if saver is permitted to run
  2926.     If CheckIfValidSaver(1) = 0 Then
  2927.       Exit Sub
  2928.     End If
  2929.     'see how many colors display can handle
  2930.     If TotalNumColors <= 256 Then 'see if palette based
  2931.       LogFile ("Saver does not work in palette display mode: " + Str$(PlotType)), 0
  2932.       NextSelection 'jump to next since this does not work
  2933.             'well with palettes
  2934.       Exit Sub
  2935.     End If
  2936.     ' set tick rate down
  2937.     Tick.Interval = 300
  2938.     ' start with original screen
  2939.     picture = original.Image
  2940.     ' start temp form same as original
  2941.     DC = original.hDC
  2942.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  2943.     'BitBlt Temp.hDC, 0, 0, ScaleWidth, ScaleHeight, hDC, 0, 0, &HCC0020
  2944.     'create hidden DC
  2945.     'ShadowDC = CreateCompatibleDC(hDC)
  2946.     'oldBM = SelectObject(ShadowDC, Original.Image)
  2947.     PlotInit = True
  2948.     'initial position is 1:1 copy
  2949.     x1 = 0
  2950.     y1 = 0
  2951.     x2 = ScaleWidth
  2952.     y2 = ScaleHeight
  2953.     'Calculate velocity limits
  2954.     MaxSpeedX = ScaleWidth * 15! / 800
  2955.     MaxSpeedY = ScaleWidth * 15! / 600
  2956.     ' zero initial velocity
  2957.     vx1 = MaxSpeedX * Rnd
  2958.     vy1 = MaxSpeedY * Rnd
  2959.     vx2 = -MaxSpeedX * Rnd
  2960.     vy2 = -MaxSpeedY * Rnd
  2961.     Pattern = &HCC0020 'Source Copy
  2962.   Else 'reset changes done by previous init
  2963.     ClearScreen
  2964.     'reset tick rate
  2965.     Tick.Interval = 50
  2966.     'destroy Device context
  2967.     'i = SelectObject(ShadowDC, oldBM)
  2968.     'i = DeleteDC(ShadowDC)
  2969.   End If
  2970.   Else  ' put run code here
  2971.     'make sure x1,y1 less than x2,y2 or swap
  2972.     If x1 > x2 Then x = x1: x1 = x2: x2 = x
  2973.     If y1 > y2 Then y = y1: y1 = y2: y2 = y
  2974.     'make sure that source box size does not
  2975.     'go below a minimum
  2976.     If x2 - x1 < 40 Then x2 = x1 + 40
  2977.     If y2 - y1 < 40 Then y2 = y1 + 40
  2978.     'Stretch Box from x1,y1 to x2,y2 onto display
  2979.     ' direct route does not work right:
  2980.     'DC = Original.hDC
  2981.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  2982.     'indirect route does not work on pallete display modes:
  2983.     DC = original.hDC
  2984.     x = x2 - x1: y = y2 - y1
  2985.     i = StretchBlt(temp.hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, DC, x1, y1, x, y, &HCC0020)
  2986.     ' now that it has been stretched, write to display
  2987.     DC = temp.hDC
  2988.     BitBlt hDC, 0, 0, ScaleWidth, ScaleHeight, DC, 0, 0, &HCC0020
  2989.     'try this method:
  2990.     'i = StretchBlt(hDC, ByVal 0, ByVal 0, ScaleWidth, ScaleHeight, ShadowDC, x1, y1, x, y, &HCC0020)
  2991.     'determine new acceleration
  2992.     ax1 = Rnd - .5
  2993.     ay1 = Rnd - .5
  2994.     ax2 = Rnd - .5
  2995.     ay2 = Rnd - .5
  2996.         
  2997.     'calculate new position
  2998.     x1 = x1 + vx1
  2999.     y1 = y1 + vy1
  3000.     x2 = x2 + vx2
  3001.     y2 = y2 + vy2
  3002.     'calculate new velocity
  3003.     vx1 = (vx1 + ax1): If Abs(vx1) > MaxSpeedX Then vx1 = 0: ax1 = 0
  3004.     vy1 = (vy1 + ay1): If Abs(vy1) > MaxSpeedY Then vy1 = 0: ay1 = 0
  3005.     vx2 = (vx2 + ax2): If Abs(vx2) > MaxSpeedX Then vx2 = 0: ax2 = 0
  3006.     vy2 = (vy2 + ay2): If Abs(vy2) > MaxSpeedY Then vy2 = 0: ay2 = 0
  3007.     'check if off screen
  3008.     If (x1 >= ScaleWidth) Then
  3009.         'change direction
  3010.         vx1 = -Abs(vx1)
  3011.         x1 = ScaleWidth - 1
  3012.     ElseIf (x1 < 0) Then
  3013.         'change direction
  3014.         vx1 = Abs(vx1)
  3015.         x1 = 0
  3016.     End If
  3017.     If (y1 >= ScaleHeight) Then
  3018.         'change direction
  3019.         vy1 = -Abs(vy1)
  3020.         y1 = ScaleHeight - 1
  3021.     ElseIf (y1 < 0) Then
  3022.         'change direction
  3023.         vy1 = Abs(vy1)
  3024.         y1 = 0
  3025.     End If
  3026.     'check if off screen
  3027.     If (x2 >= ScaleWidth) Then
  3028.         'change direction
  3029.         vx2 = -Abs(vx2)
  3030.         x2 = ScaleWidth - 1
  3031.     ElseIf (x2 < 0) Then
  3032.         'change direction
  3033.         vx2 = Abs(vx2)
  3034.         x2 = 0
  3035.     End If
  3036.     If (y2 >= ScaleHeight) Then
  3037.         'change direction
  3038.         vy2 = -Abs(vy2)
  3039.         y2 = ScaleHeight - 1
  3040.     ElseIf (y2 < 0) Then
  3041.         'change direction
  3042.         vy2 = Abs(vy2)
  3043.         y2 = 0
  3044.     End If
  3045.   End If
  3046. End Sub
  3047. Sub Tick_Timer ()
  3048.     ' check elapsed time to see if need to change type of plot
  3049.     ' also check if past midnight
  3050.     CurrentTime = Timer
  3051.     If (CurrentTime > MaxTime) Or (LastTime > CurrentTime) Then
  3052.     MaxTime = MaxChangeMinutes * 60 + CurrentTime ' calculate time in seconds
  3053.     ZOrder 0' make sure form is still on top
  3054.     'clear old saver
  3055.     PlotInit = False: PlotEnd = True
  3056.     LogFile ("Cleanup of" + Str$(PlotType)), 1
  3057.     RunSelection 'just clean up after running
  3058.     'LogFile ("After Cleanup of " + Str$(PlotType)), 1
  3059.     'see if we want random selection
  3060.     NextSelection 'get new PlotType
  3061.     PlotInit = False: PlotEnd = False
  3062.     'remove password prompt
  3063.     PasswordLabel.Visible = False
  3064.     End If
  3065.     LastTime = CurrentTime
  3066.     RunSelection
  3067. End Sub
  3068.